From 445aba2a56ab3c608df84c4a37a9da498d747af5 Mon Sep 17 00:00:00 2001 From: Matthew Hailwood Date: Thu, 9 Mar 2017 12:35:37 +1300 Subject: [PATCH] Do not default to locale if hasEmptyDefault is true Currently there is no per-instance way to say "don't default to the current locale". If you've explicitly said "This field right here, it has an empty default value" then we should probably respect that. --- forms/CountryDropdownField.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/forms/CountryDropdownField.php b/forms/CountryDropdownField.php index 61a5f0e83..885de4c1d 100644 --- a/forms/CountryDropdownField.php +++ b/forms/CountryDropdownField.php @@ -58,16 +58,18 @@ class CountryDropdownField extends DropdownField { public function Field($properties = array()) { $source = $this->getSource(); - if (!$this->value || !isset($source[$this->value])) { - if ($this->config()->default_to_locale && $this->locale()) { - $locale = new Zend_Locale(); - $locale->setLocale($this->locale()); - $this->value = $locale->getRegion(); + if(!$this->getHasEmptyDefault()){ + if (!$this->value || !isset($source[$this->value])) { + if ($this->config()->default_to_locale && $this->locale()) { + $locale = new Zend_Locale(); + $locale->setLocale($this->locale()); + $this->value = $locale->getRegion(); + } } - } - if (!$this->value || !isset($source[$this->value])) { - $this->value = $this->config()->default_country; + if (!$this->value || !isset($source[$this->value])) { + $this->value = $this->config()->default_country; + } } return parent::Field();