How to create a hidden input field in Laravel

A hidden input field is a type of <input> element which is not visible on the webpage and user can add or edit its value. You can easily generate a hidden input field in Laravel using the following code. First parameter is the name of the input field and second parameter is its value.

Useful Read : Creating a Text Input Field

{{ Form::hidden('secret', 'myValue') }}

This will generate following HTML output,

<input name="secret" type="hidden" value="myValue">

To add an id or other HTML attribute pass a third parameter in form of an associative array.

{{ Form::hidden('secret', 'myValue', array('id' => 'mySecretId')) }}

The above code will generate following output,

<input id="mySecretId" name="secret" type="hidden" value="myValue">



Leave a Comment.