From 664d25a2286b5fdef740da7a3c4d72d8fa00d530 Mon Sep 17 00:00:00 2001 From: Adam Jackett Date: Wed, 3 Jun 2015 15:54:54 -0400 Subject: made all form helpers consistent regarding extra attributes --- system/helpers/form_helper.php | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 53ee8eb11..c77069c55 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -197,7 +197,7 @@ if ( ! function_exists('form_input')) * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_input($data = '', $value = '', $extra = '') @@ -208,6 +208,8 @@ if ( ! function_exists('form_input')) 'value' => $value ); + $extra = _attributes_to_string($extra); + return '\n"; } } @@ -223,7 +225,7 @@ if ( ! function_exists('form_password')) * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_password($data = '', $value = '', $extra = '') @@ -245,7 +247,7 @@ if ( ! function_exists('form_upload')) * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_upload($data = '', $value = '', $extra = '') @@ -253,6 +255,9 @@ if ( ! function_exists('form_upload')) $defaults = array('type' => 'file', 'name' => ''); is_array($data) OR $data = array('name' => $data); $data['type'] = 'file'; + + $extra = _attributes_to_string($extra); + return '\n"; } } @@ -266,7 +271,7 @@ if ( ! function_exists('form_textarea')) * * @param mixed $data * @param string $value - * @param string $extra + * @param mixed $extra * @return string */ function form_textarea($data = '', $value = '', $extra = '') @@ -287,6 +292,8 @@ if ( ! function_exists('form_textarea')) unset($data['value']); // textareas don't use the value attribute } + $extra = _attributes_to_string($extra); + return '\n"; } } @@ -301,11 +308,13 @@ if ( ! function_exists('form_multiselect')) * @param string * @param array * @param mixed - * @param string + * @param mixed * @return string */ function form_multiselect($name = '', $options = array(), $selected = array(), $extra = '') { + $extra = _attributes_to_string($extra); + if ( ! strpos($extra, 'multiple')) { $extra .= ' multiple="multiple"'; @@ -420,7 +429,7 @@ if ( ! function_exists('form_checkbox')) * @param mixed * @param string * @param bool - * @param string + * @param mixed * @return string */ function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '') @@ -450,6 +459,8 @@ if ( ! function_exists('form_checkbox')) unset($defaults['checked']); } + $extra = _attributes_to_string($extra); + return '\n"; } } @@ -464,13 +475,16 @@ if ( ! function_exists('form_radio')) * @param mixed * @param string * @param bool - * @param string + * @param mixed * @return string */ function form_radio($data = '', $value = '', $checked = FALSE, $extra = '') { is_array($data) OR $data = array('name' => $data); $data['type'] = 'radio'; + + $extra = _attributes_to_string($extra); + return form_checkbox($data, $value, $checked, $extra); } } @@ -484,7 +498,7 @@ if ( ! function_exists('form_submit')) * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_submit($data = '', $value = '', $extra = '') @@ -495,6 +509,8 @@ if ( ! function_exists('form_submit')) 'value' => $value ); + $extra = _attributes_to_string($extra); + return '\n"; } } @@ -508,7 +524,7 @@ if ( ! function_exists('form_reset')) * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_reset($data = '', $value = '', $extra = '') @@ -519,6 +535,8 @@ if ( ! function_exists('form_reset')) 'value' => $value ); + $extra = _attributes_to_string($extra); + return '\n"; } } @@ -532,7 +550,7 @@ if ( ! function_exists('form_button')) * * @param mixed * @param string - * @param string + * @param mixed * @return string */ function form_button($data = '', $content = '', $extra = '') @@ -548,6 +566,8 @@ if ( ! function_exists('form_button')) unset($data['content']); // content is not an attribute } + $extra = _attributes_to_string($extra); + return '\n"; } } -- cgit v1.2.3-24-g4f1b