Welcome Guest, Not a member yet? Register   Sign In
Hidden field does not get id
#1

[eluser]Unknown[/eluser]
Long time troller first time poster.

Using the form gen lib and I am having an issue, the hidden field has no ID attr.
Any reason or is there an issue, or work around for this?

Thx.
#2

[eluser]Cristian Gilè[/eluser]
Hi flmike,

this is a limittation of the CI form_hidden function not of formgenlib.

In order to have id attribute in your hidden field you have to extends your form helper (http://ellislab.com/forums/viewthread/129280/)

Code:
if ( ! function_exists('form_hidden'))
{
    function form_hidden($name, $value = '', $id = false)
    {
        if ( ! is_array($name))
        {
            return '<input type="hidden" id="'.($id ? $id : $name).'" name="'.$name.'" value="'.form_prep($value).'" />';
        }

        $form = '';

        foreach ($name as $name => $value)
        {
            $form .= "\n";
            $form .= '<input type="hidden"  id="'.($id ? $id : $name).'" name="'.$name.'" value="'.form_prep($value).'" />';
        }

        return $form;
    }
}

Now, formgenlib hidden fields work like a charm.

There is a dedicated forum for formgenlib: http://ellislab.com/forums/viewthread/107861/




Theme © iAndrew 2016 - Forum software by © MyBB