Add TreeDropdownField from React to Entwine

This commit is contained in:
Christopher Joe 2017-08-30 22:41:56 +12:00 committed by Damian Mooyman
parent 458e919a69
commit 120c772966
2 changed files with 25 additions and 6 deletions

View File

@ -605,6 +605,26 @@ class TreeDropdownField extends FormField
$callback = $this->getDisableFunction();
return $callback && call_user_func($callback, $node);
}
/**
* Attributes to be given for this field type
* @return array
*/
public function getAttributes()
{
$attributes = array(
'class' => $this->extraClass(),
'id' => $this->ID(),
'data-schema' => json_encode($this->getSchemaData()),
'data-state' => json_encode($this->getSchemaState()),
);
$attributes = array_merge($attributes, $this->attributes);
$this->extend('updateAttributes', $attributes);
return $attributes;
}
/**
* @param string $field

View File

@ -1,8 +1,7 @@
<div 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 %> tabindex="0">
<div
class="TreeDropdownField<% if $extraClass %> $extraClass<% end_if %><% if $ShowSearch %> searchable<% end_if %>"
$AttributesHTML('class')
<% if $Metadata %>data-metadata="$Metadata.ATT"<% end_if %>
>
<input id="$ID" type="hidden" name="$Name.ATT" value="$Value.ATT" />
</div>