Elements

In This Article

Hidden

Zend\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 Zend\Form\Element;
use Zend\Form\Form;

$hidden = new Element\Hidden('my-hidden');
$hidden->setValue('foo');

$form = new Form('my-form');
$form->add($hidden);

Using array notation:

use Zend\Form\Element;
use Zend\Form\Form;

$form = new Form('my-form');
$form->add([
    'type' => Element\Hidden::class,
    'name' => 'my-hidden',
    'attributes' => [
        'value' => 'foo',
    ],
]);

Found a mistake or want to contribute to the documentation? Edit this page on GitHub!