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.
This commit is contained in:
Matthew Hailwood 2017-03-09 12:35:37 +13:00 committed by GitHub
parent 8aaa3e3a86
commit 445aba2a56

View File

@ -58,6 +58,7 @@ class CountryDropdownField extends DropdownField {
public function Field($properties = array()) { public function Field($properties = array()) {
$source = $this->getSource(); $source = $this->getSource();
if(!$this->getHasEmptyDefault()){
if (!$this->value || !isset($source[$this->value])) { if (!$this->value || !isset($source[$this->value])) {
if ($this->config()->default_to_locale && $this->locale()) { if ($this->config()->default_to_locale && $this->locale()) {
$locale = new Zend_Locale(); $locale = new Zend_Locale();
@ -69,6 +70,7 @@ class CountryDropdownField extends DropdownField {
if (!$this->value || !isset($source[$this->value])) { if (!$this->value || !isset($source[$this->value])) {
$this->value = $this->config()->default_country; $this->value = $this->config()->default_country;
} }
}
return parent::Field(); return parent::Field();
} }