Form

The Form view helper is used to render a <form> HTML element and its attributes.

If provided a Zend\Form\Form instance, it will:

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 \Zend\View\Renderer\PhpRenderer $this
 * @var \Zend\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 $form instance.
closeTag() : string Renders a </form> closing tag.