From eb47eb77166b990a2b98bf0bf026d716e3c2dc4f Mon Sep 17 00:00:00 2001 From: Cameron <e107inc@gmail.com> Date: Wed, 23 Dec 2020 08:35:31 -0800 Subject: [PATCH] Snippet to include id attribute. --- e107_handlers/form_handler.php | 4 +++- e107_tests/tests/unit/e_formTest.php | 2 +- e107_themes/bootstrap3/snippets/form_checkbox.html | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 04981eeda..6a110ea02 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -2441,7 +2441,7 @@ class e_form private function renderSnippet($snippet, $options, $name, $value) { - $snip = $options; + $snip = (array) $options; if(!empty($options['class'])) { @@ -2449,6 +2449,8 @@ class e_form unset($options['class']); } + $snip['id'] = $this->_format_id(varset($options['id']), $name, $value, null); + unset($options['id']); $snip['attributes'] = $this->get_attributes($options, $name, $value); foreach($snip as $k=>$v) diff --git a/e107_tests/tests/unit/e_formTest.php b/e107_tests/tests/unit/e_formTest.php index d77312d5d..358d0acfe 100644 --- a/e107_tests/tests/unit/e_formTest.php +++ b/e107_tests/tests/unit/e_formTest.php @@ -1148,7 +1148,7 @@ class e_formTest extends \Codeception\Test\Unit $result = $this->_frm->checkbox('myname', 3, true, ['readonly'=>true]); $expected = "<label class='checkbox form-check'> -<input class='form-check-input' type='checkbox' id='myname-3' readonly='readonly' checked='checked' /> +<input id='myname-3' class='form-check-input' type='checkbox' readonly='readonly' checked='checked' /> <span></span> </label>"; diff --git a/e107_themes/bootstrap3/snippets/form_checkbox.html b/e107_themes/bootstrap3/snippets/form_checkbox.html index dadea820a..d23e0d3bd 100644 --- a/e107_themes/bootstrap3/snippets/form_checkbox.html +++ b/e107_themes/bootstrap3/snippets/form_checkbox.html @@ -1,4 +1,4 @@ <label class='checkbox form-check'> -<input class='{class}' type='checkbox' {attributes} /> +<input id='{id}' class='{class}' type='checkbox' {attributes} /> <span>{label}</span> </label> \ No newline at end of file