mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #4272 from dhensby/pulls/tree-dropdown-fix
FIX TreeDropdownField doesnt change label on unselect
This commit is contained in:
commit
6facb1bf5d
@ -216,15 +216,20 @@ class TreeDropdownField extends FormField {
|
|||||||
Requirements::css(FRAMEWORK_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css');
|
Requirements::css(FRAMEWORK_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css');
|
||||||
Requirements::css(FRAMEWORK_DIR . '/css/TreeDropdownField.css');
|
Requirements::css(FRAMEWORK_DIR . '/css/TreeDropdownField.css');
|
||||||
|
|
||||||
|
if($this->showSearch) {
|
||||||
|
$emptyTitle = _t('DropdownField.CHOOSESEARCH', '(Choose or Search)', 'start value of a dropdown');
|
||||||
|
} else {
|
||||||
|
$emptyTitle = _t('DropdownField.CHOOSE', '(Choose)', 'start value of a dropdown');
|
||||||
|
}
|
||||||
|
|
||||||
$record = $this->Value() ? $this->objectForKey($this->Value()) : null;
|
$record = $this->Value() ? $this->objectForKey($this->Value()) : null;
|
||||||
if($record instanceof ViewableData) {
|
if($record instanceof ViewableData) {
|
||||||
$title = $record->obj($this->labelField)->forTemplate();
|
$title = $record->obj($this->labelField)->forTemplate();
|
||||||
} elseif($record) {
|
} elseif($record) {
|
||||||
$title = Convert::raw2xml($record->{$this->labelField});
|
$title = Convert::raw2xml($record->{$this->labelField});
|
||||||
} else if($this->showSearch) {
|
}
|
||||||
$title = _t('DropdownField.CHOOSESEARCH', '(Choose or Search)', 'start value of a dropdown');
|
else {
|
||||||
} else {
|
$title = $emptyTitle;
|
||||||
$title = _t('DropdownField.CHOOSE', '(Choose)', 'start value of a dropdown');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Implement for TreeMultiSelectField
|
// TODO Implement for TreeMultiSelectField
|
||||||
@ -237,6 +242,7 @@ class TreeDropdownField extends FormField {
|
|||||||
$properties,
|
$properties,
|
||||||
array(
|
array(
|
||||||
'Title' => $title,
|
'Title' => $title,
|
||||||
|
'EmptyTitle' => $emptyTitle,
|
||||||
'Metadata' => ($metadata) ? Convert::raw2json($metadata) : null,
|
'Metadata' => ($metadata) ? Convert::raw2json($metadata) : null,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -165,6 +165,10 @@
|
|||||||
}
|
}
|
||||||
if(node) tree.jstree('select_node', node);
|
if(node) tree.jstree('select_node', node);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
self.setTitle(self.data('empty-title'));
|
||||||
|
self.removeData('title');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load the tree if its not already present
|
// Load the tree if its not already present
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
class="TreeDropdownField <% if $extraClass %> $extraClass<% end_if %><% if $ShowSearch %> searchable<% end_if %>"
|
class="TreeDropdownField <% if $extraClass %> $extraClass<% end_if %><% if $ShowSearch %> searchable<% end_if %>"
|
||||||
data-url-tree="$Link('tree')"
|
data-url-tree="$Link('tree')"
|
||||||
data-title="$Title.ATT"
|
data-title="$Title.ATT"
|
||||||
|
data-empty-title="$EmptyTitle.ATT"
|
||||||
<% if $Description %>title="$Description.ATT"<% end_if %>
|
<% if $Description %>title="$Description.ATT"<% end_if %>
|
||||||
<% if $Metadata %>data-metadata="$Metadata.ATT"<% end_if %>>
|
<% if $Metadata %>data-metadata="$Metadata.ATT"<% end_if %>>
|
||||||
<input id="$ID" type="hidden" name="$Name.ATT" value="$Value.ATT" />
|
<input id="$ID" type="hidden" name="$Name.ATT" value="$Value.ATT" />
|
||||||
|
Loading…
Reference in New Issue
Block a user