Skip to content

Commit

Permalink
FIX Treat value not in SingleSelectField options as blank
Browse files Browse the repository at this point in the history
This makes the react dropdown fields behave more like the entwine ones when the DB value is not in the set of dropdown options.
  • Loading branch information
GuySartorelli committed Dec 12, 2024
1 parent bd7c2af commit 14f8649
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Forms/SingleSelectField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 14f8649

Please sign in to comment.