Commit efbc8fd0 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '6138-selectattribute-should-also-reset-postvalue-is-setchoices' into '1.4-dev'

Resolve "SelectAttribute should also reset postValue is setChoices"

See merge request fusiondirectory/fd!847
Showing with 10 additions and 2 deletions
+10 -2
...@@ -76,8 +76,12 @@ class SelectAttribute extends Attribute ...@@ -76,8 +76,12 @@ class SelectAttribute extends Attribute
} }
} }
$this->choices = $choices; $this->choices = $choices;
if (!in_array($this->defaultValue, $this->choices, TRUE) && isset($this->choices[0])) { if (!in_array($this->defaultValue, $this->choices, TRUE)) {
$this->defaultValue = $this->choices[0]; if (isset($this->choices[0])) {
$this->defaultValue = $this->choices[0];
} else {
$this->defaultValue = '';
}
} }
if (is_array($outputs)) { if (is_array($outputs)) {
$this->setDisplayChoices($outputs); $this->setDisplayChoices($outputs);
...@@ -85,6 +89,10 @@ class SelectAttribute extends Attribute ...@@ -85,6 +89,10 @@ class SelectAttribute extends Attribute
if (!in_array($this->value, $this->choices)) { if (!in_array($this->value, $this->choices)) {
$this->resetToDefault(); $this->resetToDefault();
} }
if (!in_array($this->postValue, $this->choices)) {
/* We may be called between readPostValue and applyPostValue */
$this->postValue = $this->defaultValue;
}
} }
/*! \brief Set the display options of the select attribute /*! \brief Set the display options of the select attribute
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment