Welcome Guest, Not a member yet? Register   Sign In
Form Helper: Hidden Input and Validation: Checkbox Arrays
#2

[eluser]xwero[/eluser]
The form_hidden has no extra parameter i think this has to do with the possibility to add hidden inputs with the form_open tag but it can be fixed.
Code:
function form_hidden($name, $value = '', $extra = '')
{
    if ( ! is_array($name))
    {
        return '<input type="hidden" name="'.$name.'" value="'.form_prep($value).'" '.$extra.' />';
    }

    $form = '';
    foreach ($name as $name => $attr)
    {
        // second ternary conditional added to be compatible with the current function behavior
            $value = (isset($attr['value']))?form_prep($attr['value']):(is_string($attr)?$attr:'');
            $extra = (isset($attr['extra']))?$attr['extra']:'';
            $form .= '<input type="hidden" name="'.$name.'" value="'.$value.'" '.$extra.' />';
    }
    
    return $form;
}
The usages for adding more than one input with one form_hidden function is
Code:
$hiddens = array('name1'=>array('value'=>'value1','extra'=>'id="1"'),
                 'name2'=>array('value'=>'value2','extra'=>'id="2"'));
form_hidden($hiddens);
// or
form_open('method/controller','',$hiddens);


Messages In This Thread
Form Helper: Hidden Input and Validation: Checkbox Arrays - by El Forum - 05-08-2008, 12:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB