On this page
View Helpers
Form
The Form view helper is used to render a <form> HTML element and its
attributes.
If provided a Laminas\Form\Form instance, it will:
- prepare()the instance
- iterate it, and:- pass non-collection Laminas\Form\Elementinstances to theFormRowhelper to render, and
- pass collections and fieldsets to the FormCollectionhelper to render.
 
- pass non-collection 
For more fine-grained control, us the form() helper only for emitting the
opening and closing <form> tags, and manually use other helpers to render the
individual elements and fieldsets.
Basic usage
/**
 * inside a view template
 *
 * @var \Laminas\View\Renderer\PhpRenderer $this
 * @var \Laminas\Form\Form $form
 */
echo $this->form($form);might result in markup like the following:
<form action="" method="POST">
   <label>
      <span>Some Label</span>
      <input type="text" name="some_element" value="">
   </label>
</form>Public methods
The following public methods are in addition to those inherited from the AbstractHelper:
| Method signature | Description | 
|---|---|
| __invoke(FormInterface $form = null) : string | Prepares and renders the whole form. | 
| openTag(FormInterface $form = null) : string | Renders the <form>open tag for the$forminstance. | 
| closeTag() : string | Renders a </form>closing tag. |