From 120c7729668b2b676e291e67db1e1c4666edce9f Mon Sep 17 00:00:00 2001 From: Christopher Joe Date: Wed, 30 Aug 2017 22:41:56 +1200 Subject: [PATCH] Add TreeDropdownField from React to Entwine --- src/Forms/TreeDropdownField.php | 20 +++++++++++++++++++ .../SilverStripe/Forms/TreeDropdownField.ss | 11 +++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Forms/TreeDropdownField.php b/src/Forms/TreeDropdownField.php index 23cfda353..2bea56ae9 100644 --- a/src/Forms/TreeDropdownField.php +++ b/src/Forms/TreeDropdownField.php @@ -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 diff --git a/templates/SilverStripe/Forms/TreeDropdownField.ss b/templates/SilverStripe/Forms/TreeDropdownField.ss index ed4eaa4a8..fad2a4e5f 100644 --- a/templates/SilverStripe/Forms/TreeDropdownField.ss +++ b/templates/SilverStripe/Forms/TreeDropdownField.ss @@ -1,8 +1,7 @@ -
title="$Description.ATT"<% end_if %> - <% if $Metadata %>data-metadata="$Metadata.ATT"<% end_if %> tabindex="0"> +
data-metadata="$Metadata.ATT"<% end_if %> +>