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]";
}
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'])
);
}