On this page
Caution
The documentation you are viewing is for an older version of this component.
Switch to the latest (v3) version.
Elements
Hidden
Laminas\Form\Element\Hidden
represents a hidden form input.
It can be used with the FormHidden view helper.
Basic Usage
This element automatically adds a type
attribute of value hidden
.
use Laminas\Form\Element;
use Laminas\Form\Form;
$hidden = new Element\Hidden('my-hidden');
$hidden->setValue('foo');
$form = new Form('my-form');
$form->add($hidden);
Using array notation:
use Laminas\Form\Element;
use Laminas\Form\Form;
$form = new Form('my-form');
$form->add([
'type' => Element\Hidden::class,
'name' => 'my-hidden',
'attributes' => [
'value' => 'foo',
],
]);