form_hidden()

form_hidden($name[, $value = ''])

Parameters:
  • $name (string) – Field name
  • $value (string) – Field value
Returns:

An HTML hidden input field tag

Return type:

string

Lets you generate hidden input fields. You can either submit a name/value string to create one field:

form_hidden('username', 'johndoe');
// Would produce: <input type="hidden" name="username" value="johndoe" />

... or you can submit an associative array to create multiple fields:

$data = array(
        'name'  => 'John Doe',
        'email' => '[email protected]',
        'url'   => 'http://example.com'
);

echo form_hidden($data);

/*
        Would produce:
        <input type="hidden" name="name" value="John Doe" />
        <input type="hidden" name="email" value="[email protected]" />
        <input type="hidden" name="url" value="http://example.com" />
*/

You can also pass an associative array to the value field:

$data = array(
        'name'  => 'John Doe',
        'email' => '[email protected]',
        'url'   => 'http://example.com'
);

echo form_hidden('my_array', $data);

/*
        Would produce:

        <input type="hidden" name="my_array[name]" value="John Doe" />
        <input type="hidden" name="my_array[email]" value="[email protected]" />
        <input type="hidden" name="my_array[url]" value="http://example.com" />
*/

If you want to create hidden input fields with extra attributes:

$data = array(
        'type'  => 'hidden',
        'name'  => 'email',
        'id'    => 'hiddenemail',
        'value' => '[email protected]',
        'class' => 'hiddenemail'
);

echo form_input($data);

/*
        Would produce:

        <input type="hidden" name="email" value="[email protected]" id="hiddenemail" class="hiddenemail" />
*/
doc_CodeIgniter
2016-10-15 16:32:19
Comments
Leave a Comment

Please login to continue.