diff --git a/src/Forms/Select.php b/src/Forms/Select.php index 6ea2ebe..f2cd456 100644 --- a/src/Forms/Select.php +++ b/src/Forms/Select.php @@ -156,6 +156,8 @@ public function __toString(): string private function selectDropdown(): Element { $elements = []; + + $hasWarningMessage = (self::warningMessage() !== ''); foreach ($this->options as $value => $content) { $value = (string) $value; $option = Element::option($content)->props('value ' . $value); @@ -168,7 +170,7 @@ private function selectDropdown(): Element $input = Element::select( ...$elements )->props('id ' . $this->name, 'name ' . $this->name); - if (self::warningMessage() !== '') { + if ($hasWarningMessage) { $input = $input->prop('aria-invalid true'); $input = $input->prop('aria-describedby ' . $this->warningId); }