O'Reilly logo

Zend Framework 2 Cookbook by Josephus Callaars

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using form view helpers

Instead of the Zend Framework 1 Decorators (where it was a key in the creation and rendering of forms) we now know in Zend Framework 2 that it is better to use different view helpers and renderers to render the forms.

How to do it…

View helpers are very important tools to a developer, here we will discuss how to use them in our code.

Form

We do the following alterations to a view script called example-viewscript.phtml:

<?php

// Just open and close the form tag
echo $this->form()->openTag();
echo $this->form()->closeTag();


// Use a form to pull the attributes from
echo $this->form()->openTag($formObject);


/** Do stuff in between **/

// Close the tag again with no form object attached
echo $this->form->closeTag();

The rendered ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required