diff --git a/src/Forms/SingleSelectField.php b/src/Forms/SingleSelectField.php index 1dcd6b502ed..44b1a7619ee 100644 --- a/src/Forms/SingleSelectField.php +++ b/src/Forms/SingleSelectField.php @@ -53,12 +53,13 @@ public function getSchemaDataDefaults() public function getDefaultValue() { $value = $this->Value(); + $validValues = $this->getValidValues(); // assign value to field, such as first option available - if ($value === null) { + if ($value === null || !in_array($value, $validValues)) { if ($this->getHasEmptyDefault()) { $value = ''; } else { - $values = $this->getValidValues(); + $values = $validValues; $value = array_shift($values); } }