summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorAdam Jackett <adam@darkhouse.ca>2015-06-03 21:54:54 +0200
committerAdam Jackett <adam@darkhouse.ca>2015-06-03 21:54:54 +0200
commit664d25a2286b5fdef740da7a3c4d72d8fa00d530 (patch)
treeb2f1d3ff8540c651b33ac66893a3cc8cd6f19d84 /system/helpers
parente3216319e56de5e4214e5fec04af5bebaa593d0c (diff)
made all form helpers consistent regarding extra attributes
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/form_helper.php40
1 files changed, 30 insertions, 10 deletions
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 '<input '._parse_form_attributes($data, $defaults).$extra." />\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 '<input '._parse_form_attributes($data, $defaults).$extra." />\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 '<textarea '._parse_form_attributes($data, $defaults).$extra.'>'.html_escape($val)."</textarea>\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 '<input '._parse_form_attributes($data, $defaults).$extra." />\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 '<input '._parse_form_attributes($data, $defaults).$extra." />\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 '<input '._parse_form_attributes($data, $defaults).$extra." />\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 '<button '._parse_form_attributes($data, $defaults).$extra.'>'.$content."</button>\n";
}
}