From 415cd596f86816ad6a6e6be50882e276ffdf183a Mon Sep 17 00:00:00 2001 From: Rida Abou-Haidar Date: Wed, 9 Aug 2023 18:22:01 -0400 Subject: [PATCH 1/2] [LorisForm] add required to checkboxes --- php/libraries/LorisForm.class.inc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/php/libraries/LorisForm.class.inc b/php/libraries/LorisForm.class.inc index bc29b94bc18..8a3211d37e8 100644 --- a/php/libraries/LorisForm.class.inc +++ b/php/libraries/LorisForm.class.inc @@ -1592,6 +1592,7 @@ class LorisForm $checked = ''; $value = ''; $disabled = ''; + $required = ''; if (!empty($val)) { $checked = 'checked="checked"'; } @@ -1601,6 +1602,9 @@ class LorisForm if (isset($el['disabled']) || $this->frozen) { $disabled = 'disabled'; } + if (isset($el['required'])) { + $required = 'required'; + } /// XXX: There seems to be a problem when using   to separate the // checkbox from the label. Both Firefox and Chrome will still put a // linebreak between the space and the checkbox. Instead, we wrap use @@ -1609,7 +1613,7 @@ class LorisForm // label it's still allowed to have linebreaks. return "" + . "$disabled $required/>" . " $el[label]"; } From 6d0a562b10893b11855c52a2155eef201a85bb64 Mon Sep 17 00:00:00 2001 From: Rida Abou-Haidar Date: Thu, 10 Aug 2023 07:45:43 -0400 Subject: [PATCH 2/2] Update LorisForms_Test.php --- test/unittests/LorisForms_Test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unittests/LorisForms_Test.php b/test/unittests/LorisForms_Test.php index 276616dbb56..61b269c357e 100644 --- a/test/unittests/LorisForms_Test.php +++ b/test/unittests/LorisForms_Test.php @@ -1336,7 +1336,7 @@ function testCheckboxHTMLWithNoAttributes() $this->form->addCheckbox("abc", "Hello", []); $this->assertEquals( " Hello", + "type=\"checkbox\" /> Hello", $this->form->checkboxHTML($this->form->form['abc']) ); } @@ -1358,7 +1358,7 @@ function testCheckboxHTMLWithAttributesSet() $this->assertEquals( " Hello", + " value=\"value1\" disabled /> Hello", $this->form->checkboxHTML($this->form->form['abc']) ); }