mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT HTML titles in TreeDropdownField
HTML in tree nodes is already used to render page icons via SiteTree->TreeTitle. In order to select the initial value correctly via HTML5 data attributes, we need to encode any HTML values.
This commit is contained in:
parent
2a52ce2ff8
commit
6c1f7997a4
@ -188,6 +188,7 @@ class TreeDropdownField extends FormField {
|
|||||||
$properties,
|
$properties,
|
||||||
array(
|
array(
|
||||||
'Title' => $title,
|
'Title' => $title,
|
||||||
|
'TitleURLEncoded' => rawurlencode($title),
|
||||||
'Metadata' => ($metadata) ? Convert::raw2att(Convert::raw2json($metadata)) : null
|
'Metadata' => ($metadata) ? Convert::raw2att(Convert::raw2json($metadata)) : null
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -38,8 +38,7 @@
|
|||||||
|
|
||||||
var linkTitle = strings.openLink;
|
var linkTitle = strings.openLink;
|
||||||
if(linkTitle) this.find("treedropdownfield-toggle-panel-link a").attr('title', linkTitle);
|
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.getPanel().hide();
|
||||||
this._super();
|
this._super();
|
||||||
@ -111,8 +110,8 @@
|
|||||||
setTitle: function(title) {
|
setTitle: function(title) {
|
||||||
if(!title) title = strings.fieldTitle;
|
if(!title) title = strings.fieldTitle;
|
||||||
|
|
||||||
this.find('.treedropdownfield-title').text(title);
|
this.find('.treedropdownfield-title').html(title);
|
||||||
this.data('title', title); // separate view from storage (important for search cancellation)
|
this.data('title', encodeURIComponent(title)); // separate view from storage (important for search cancellation)
|
||||||
},
|
},
|
||||||
getTitle: function() {
|
getTitle: function() {
|
||||||
return this.find('.treedropdownfield-title').text();
|
return this.find('.treedropdownfield-title').text();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<div id="TreeDropdownField_$ID"
|
<div id="TreeDropdownField_$ID"
|
||||||
class="TreeDropdownField single<% if extraClass %> $extraClass<% end_if %><% if ShowSearch %> searchable<% end_if %>"
|
class="TreeDropdownField single<% if extraClass %> $extraClass<% end_if %><% if ShowSearch %> searchable<% end_if %>"
|
||||||
data-url-tree="$Link(tree)"
|
data-url-tree="$Link(tree)"
|
||||||
data-title="$Title"
|
data-title="$TitleURLEncoded"
|
||||||
<% if Description %>title="$Description"<% end_if %>
|
<% if Description %>title="$Description"<% end_if %>
|
||||||
<% if Metadata %>data-metadata="$Metadata"<% end_if %>>
|
<% if Metadata %>data-metadata="$Metadata"<% end_if %>>
|
||||||
<input id="$ID" type="hidden" name="$Name" value="$Value" />
|
<input id="$ID" type="hidden" name="$Name" value="$Value" />
|
||||||
|
Loading…
Reference in New Issue
Block a user