mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #3829 from silverstripe/pulls/fix-cms-1157
Fix issue where TreeDropdownField loses value on show/hide
This commit is contained in:
commit
eeacbb1b95
@ -213,8 +213,7 @@ class TreeDropdownField extends FormField {
|
||||
$properties,
|
||||
array(
|
||||
'Title' => $title,
|
||||
'TitleURLEncoded' => rawurlencode($title),
|
||||
'Metadata' => ($metadata) ? Convert::raw2att(Convert::raw2json($metadata)) : null
|
||||
'Metadata' => ($metadata) ? Convert::raw2json($metadata) : null,
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
||||
|
||||
var linkTitle = strings.openLink;
|
||||
if(linkTitle) this.find("treedropdownfield-toggle-panel-link a").attr('title', linkTitle);
|
||||
if(this.data('title')) this.setTitle(decodeURIComponent(this.data('title')));
|
||||
if(this.data('title')) this.setTitle(this.data('title'));
|
||||
|
||||
this.getPanel().hide();
|
||||
this._super();
|
||||
@ -138,10 +138,10 @@
|
||||
this[this.getPanel().is(':visible') ? 'closePanel' : 'openPanel']();
|
||||
},
|
||||
setTitle: function(title) {
|
||||
if(!title) title = strings.fieldTitle;
|
||||
title = title || this.data('title') || strings.fieldTitle;
|
||||
|
||||
this.find('.treedropdownfield-title').html(title);
|
||||
this.data('title', encodeURIComponent(title)); // separate view from storage (important for search cancellation)
|
||||
this.data('title', title); // separate view from storage (important for search cancellation)
|
||||
},
|
||||
getTitle: function() {
|
||||
return this.find('.treedropdownfield-title').text();
|
||||
|
@ -1,8 +1,8 @@
|
||||
<div id="TreeDropdownField_$ID"
|
||||
class="TreeDropdownField single<% if extraClass %> $extraClass<% end_if %><% if ShowSearch %> searchable<% end_if %>"
|
||||
data-url-tree="$Link(tree)"
|
||||
data-title="$TitleURLEncoded"
|
||||
<% if $Description %>title="$Description"<% end_if %>
|
||||
<% if $Metadata %>data-metadata="$Metadata"<% end_if %>>
|
||||
<input id="$ID" type="hidden" name="$Name" value="$Value" />
|
||||
data-title="$Title.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" />
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user