Skip to content

Commit

Permalink
SelectElement turns all options into strings now
Browse files Browse the repository at this point in the history
  • Loading branch information
J1b1x committed Jan 11, 2024
1 parent a991f53 commit e242c55
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Jibix/Forms/element/SelectElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public function __construct(
?Closure $onSubmit = null
){
parent::__construct($text, $onSubmit);
$this->options = array_values($options);
foreach ($options as $option) {
$this->options[] = (string)$option;
}
}

public function getOptions(): array{
Expand All @@ -44,6 +46,6 @@ public function getSelectedOption(): string{

protected function validateValue(mixed $value): void{
if (!is_int($value)) throw new FormValidationException("Expected int, got " . gettype($value));
if (!isset($this->options[$value])) throw new FormValidationException("Option {$value} does not exist");
if (!isset($this->options[$value])) throw new FormValidationException("Option $value does not exist");
}
}

0 comments on commit e242c55

Please sign in to comment.