From 48dec4fb274db2a068c569de3fa264eb220c85c0 Mon Sep 17 00:00:00 2001 From: Josh Bruce Date: Sun, 4 Oct 2026 16:51:22 -0400 Subject: [PATCH] refactor: Only call warning message once for check --- src/Forms/Select.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Forms/Select.php b/src/Forms/Select.php index b70376e..6ea2ebe 100644 --- a/src/Forms/Select.php +++ b/src/Forms/Select.php @@ -186,6 +186,8 @@ private function selectOther(): Element { $elements = []; $type = $this->type === SelectType::Checkbox ? 'checkbox' : 'radio'; + + $hasWarningMessage = (self::warningMessage() !== ''); foreach ($this->options as $value => $content) { $value = (string) $value; $id = $this->name . '-' . $value; @@ -203,14 +205,14 @@ private function selectOther(): Element $input = $input->prop('checked checked'); } - if (self::warningMessage() !== '') { + if ($hasWarningMessage) { $input = $input->prop('aria-invalid true'); $input = $input->prop('aria-describedby ' . $this->warningId); } $elements[] = Element::div($input, $label); } - if (self::warningMessage() !== '') { + if ($hasWarningMessage) { $elements[] = self::warningMessage(); }