From 3cdb1c95a405b1b2a77328aeceb638d6813be4bc Mon Sep 17 00:00:00 2001 From: campbell-m <87438215+campbell-m@users.noreply.github.com> Date: Sun, 27 Oct 2024 18:26:16 +0000 Subject: [PATCH] Don't bother adding a class if it's already set --- web/lib/MRBS/Form/Element.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/lib/MRBS/Form/Element.php b/web/lib/MRBS/Form/Element.php index d023532ac5..964cfe113e 100644 --- a/web/lib/MRBS/Form/Element.php +++ b/web/lib/MRBS/Form/Element.php @@ -190,8 +190,11 @@ public function addClass(string $class) : Element $classes = $this->getAttribute('class'); $classes = (isset($classes)) ? explode(' ', $classes) : array(); - $classes[] = $class; - $this->setAttribute('class', implode(' ', $classes)); + if (!in_array($class, $classes)) + { + $classes[] = $class; + $this->setAttribute('class', implode(' ', $classes)); + } return $this; }