From b64cf1e5d59b6e1eb2cab1abbe576f0c98956d9a Mon Sep 17 00:00:00 2001 From: Martynas Barzda Date: Sat, 13 Oct 2012 16:34:18 +0300 Subject: [PATCH] Form Helper: add id atributtes for form inputs If label is clicked, form input assigned with label cannot be focused, because input has not "id" attribute. ```php Form::label('field_name', 'It is label'). Form::input('filed_name', 'It is input') ``` ##Before fix generates: ```html ``` ##After fix generates: ```html ``` --- monstra/helpers/form.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/monstra/helpers/form.php b/monstra/helpers/form.php index 9192343..e6e6538 100644 --- a/monstra/helpers/form.php +++ b/monstra/helpers/form.php @@ -136,6 +136,9 @@ // Set the input name $attributes['name'] = $name; + + // Set the input id + $attributes['id'] = (isset($attributes['id']))?$attributes['id']:$name; // Set the input value $attributes['value'] = $value; @@ -286,6 +289,9 @@ // Set the input name $attributes['name'] = $name; + + // Set the input id + $attributes['id'] = (isset($attributes['id']))?$attributes['id']:$name; return ''.$body.''; } @@ -310,6 +316,9 @@ // Set the input name $attributes['name'] = $name; + // Set the input id + $attributes['id'] = (isset($attributes['id']))?$attributes['id']:$name; + $options_output = ''; foreach ($options as $value => $name) {