From 6417875f6437cc0a633138ba97bf72640a8c6507 Mon Sep 17 00:00:00 2001 From: jkRoberts Date: Wed, 8 Feb 2017 10:23:00 +1300 Subject: [PATCH] FIX: Fixing default string creator. --- code/AdvancedDropdownField.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/code/AdvancedDropdownField.php b/code/AdvancedDropdownField.php index 90121c9..504c7f1 100644 --- a/code/AdvancedDropdownField.php +++ b/code/AdvancedDropdownField.php @@ -8,15 +8,21 @@ class AdvancedDropdownField extends DropDownField { public function Field($properties = array()) { $source = $this->getSource(); $options = array(); + + if ($this->getHasEmptyDefault()) { + $selected = ($this->value === '' || $this->value === null); + $disabled = (in_array('', $this->disabledItems, true)) ? 'disabled' : false; + $empty = $this->getEmptyString(); + $options[] = new ArrayData(array( + 'Value' => '', + 'Title' => $empty['Title'], + 'Selected' => $selected, + 'Disabled' => $disabled, + 'Attributes' => $this->createOptionAttributes($empty) + )); + } + if($source) { - // SQLMap needs this to add an empty value to the options - if(is_object($source) && $this->emptyString) { - $options[] = new ArrayData(array( - 'Value' => '', - 'Title' => $this->emptyString, - )); - } - foreach($source as $value => $params) {