summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Sowell <robin.sowell@ellislab.com>2009-03-26 19:58:46 +0100
committerRobin Sowell <robin.sowell@ellislab.com>2009-03-26 19:58:46 +0100
commit57fe41072c9d97d3cba2cd5faef529ac94571bfb (patch)
treedfbd1ed538a2be4155bb1f35d1a7664e4ec57a65
parent50d45c0c4332e942a2f11d37f5f6fe0f0efc79e3 (diff)
Modified form_hidden() to accept multi-dimensional arrays.
-rw-r--r--system/helpers/form_helper.php32
1 files changed, 24 insertions, 8 deletions
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 05616f707..0173340c5 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -103,19 +103,35 @@ if ( ! function_exists('form_open_multipart'))
*/
if ( ! function_exists('form_hidden'))
{
- function form_hidden($name, $value = '')
+ function form_hidden($name, $value = '', $recursing = FALSE)
{
- if ( ! is_array($name))
+ static $form;
+
+ if ($recursing === FALSE)
{
- return '<input type="hidden" name="'.$name.'" value="'.form_prep($value).'" />';
+ $form = "\n";
}
- $form = '';
+ if (is_array($name))
+ {
+ foreach ($name as $key => $val)
+ {
+ form_hidden($key, $val, TRUE);
+ }
+ return $form;
+ }
- foreach ($name as $name => $value)
+ if ( ! is_array($value))
+ {
+ $form .= '<input type="hidden" name="'.$name.'" value="'.form_prep($value).'" />'."\n";
+ }
+ else
{
- $form .= "\n";
- $form .= '<input type="hidden" name="'.$name.'" value="'.form_prep($value).'" />';
+ foreach ($value as $k => $v)
+ {
+ $k = (is_int($k)) ? '' : $k;
+ form_hidden($name.'['.$k.']', $v, TRUE);
+ }
}
return $form;
@@ -264,7 +280,7 @@ if ( ! function_exists('form_dropdown'))
$multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
$form = '<select name="'.$name.'"'.$extra.$multiple.">\n";
-
+
foreach ($options as $key => $val)
{
$key = (string) $key;