diff --git a/src/Class-CustomForm.php b/src/Class-CustomForm.php index 625665b..a549887 100644 --- a/src/Class-CustomForm.php +++ b/src/Class-CustomForm.php @@ -170,7 +170,7 @@ public function setHtml() } public function validate(): bool { - $found = isset(array_flip($this->type_vars)[$this->value]); + $found = isset(array_flip($this->type_vars)[$this->value]) || !empty($this->default); if (!$found && $this->required) $this->err = array('pf_invalid_value', $this->field['name']); diff --git a/tests/Test.php b/tests/Test.php index aeae80d..a634db4 100644 --- a/tests/Test.php +++ b/tests/Test.php @@ -78,7 +78,8 @@ public function selectProvider(): array { return [ ['gold,silver,bronze,default=silver', '', 'silver'], - ['gold,silver,bronze,default=', 'silver', 'silver'] + ['gold,silver,bronze,default=', 'silver', 'silver'], + ['gold,silver,bronze,default=silver', 'titanium', 'silver'] ]; }