summaryrefslogtreecommitdiff
path: root/app/Helper/FormHelper.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-11-27 18:33:00 -0500
committerFrederic Guillot <fred@kanboard.net>2016-11-27 18:33:00 -0500
commitde2501f070a7bf41b766ee1139d1322213e387e9 (patch)
treed6a2c53ce9c70e40d6e412b72e5eeb04e3a0e2c4 /app/Helper/FormHelper.php
parentde1b9416d2c359e57f386760cfa29f2a12bf5b51 (diff)
Improve tabindex for project settings forms
Diffstat (limited to 'app/Helper/FormHelper.php')
-rw-r--r--app/Helper/FormHelper.php32
1 files changed, 25 insertions, 7 deletions
diff --git a/app/Helper/FormHelper.php b/app/Helper/FormHelper.php
index e44c5d06..fb088d23 100644
--- a/app/Helper/FormHelper.php
+++ b/app/Helper/FormHelper.php
@@ -131,16 +131,34 @@ class FormHelper extends Base
* Display a checkbox field
*
* @access public
- * @param string $name Field name
- * @param string $label Form label
- * @param string $value Form value
- * @param boolean $checked Field selected or not
- * @param string $class CSS class
+ * @param string $name Field name
+ * @param string $label Form label
+ * @param string $value Form value
+ * @param boolean $checked Field selected or not
+ * @param string $class CSS class
+ * @param array $attributes
* @return string
*/
- public function checkbox($name, $label, $value, $checked = false, $class = '')
+ public function checkbox($name, $label, $value, $checked = false, $class = '', array $attributes = array())
{
- return '<label><input type="checkbox" name="'.$name.'" class="'.$class.'" value="'.$this->helper->text->e($value).'" '.($checked ? 'checked="checked"' : '').'>&nbsp;'.$this->helper->text->e($label).'</label>';
+ $htmlAttributes = '';
+
+ if ($checked) {
+ $attributes['checked'] = 'checked';
+ }
+
+ foreach ($attributes as $attribute => $value) {
+ $htmlAttributes .= sprintf('%s="%s"', $attribute, $this->helper->text->e($value));
+ }
+
+ return sprintf(
+ '<label><input type="checkbox" name="%s" class="%s" value="%s" %s>&nbsp;%s</label>',
+ $name,
+ $class,
+ $this->helper->text->e($value),
+ $htmlAttributes,
+ $this->helper->text->e($label)
+ );
}
/**