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 . '/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;
|
||||
if($record instanceof ViewableData) {
|
||||
$title = $record->obj($this->labelField)->forTemplate();
|
||||
} elseif($record) {
|
||||
$title = Convert::raw2xml($record->{$this->labelField});
|
||||
} else if($this->showSearch) {
|
||||
$title = _t('DropdownField.CHOOSESEARCH', '(Choose or Search)', 'start value of a dropdown');
|
||||
} else {
|
||||
$title = _t('DropdownField.CHOOSE', '(Choose)', 'start value of a dropdown');
|
||||
}
|
||||
else {
|
||||
$title = $emptyTitle;
|
||||
}
|
||||
|
||||
// TODO Implement for TreeMultiSelectField
|
||||
@ -237,6 +242,7 @@ class TreeDropdownField extends FormField {
|
||||
$properties,
|
||||
array(
|
||||
'Title' => $title,
|
||||
'EmptyTitle' => $emptyTitle,
|
||||
'Metadata' => ($metadata) ? Convert::raw2json($metadata) : null,
|
||||
)
|
||||
);
|
||||
|
@ -165,6 +165,10 @@
|
||||
}
|
||||
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
|
||||
|
@ -2,6 +2,7 @@
|
||||
class="TreeDropdownField <% if $extraClass %> $extraClass<% end_if %><% if $ShowSearch %> searchable<% end_if %>"
|
||||
data-url-tree="$Link('tree')"
|
||||
data-title="$Title.ATT"
|
||||
data-empty-title="$EmptyTitle.ATT"
|
||||
<% if $Description %>title="$Description.ATT"<% end_if %>
|
||||
<% if $Metadata %>data-metadata="$Metadata.ATT"<% end_if %>>
|
||||
<input id="$ID" type="hidden" name="$Name.ATT" value="$Value.ATT" />
|
||||
|
Loading…
Reference in New Issue
Block a user