Skip Navigation LinksHome > Categories > Code from a Category

Connect Zend Form

User Name: serfcompany
Name: Serf
Contact Me:
Home Page:
php,mysql,javascript,html,css. Preferable working with Zend Framework. Good know javascript. I worked with various, javascript frameworks such as(jquery, YUI3, extjs, sencha touch). [More]
Viewed Times: 1868
Add Date: 06/27/2012
The article shows how the standard method of connecting forms Zend Framework.

We will assume that you have already installed Zend Tool.

Consequently, we go in Zend Tool and select your working directory: c :/ xampp / htdocs / projects / zf.local / www (this is my, you will have your way).

Execute command zf create form simple.

As a result of command in the directory of your site www / application / forms / file appears Simple.php with this content:

This is the shape of our future. At the moment it is empty and there's not connected, so we create a form for the elements: field login, password and click submit.

To do this, add the following code in our function init (), which will display a form in the right place:

Now we have finished the form, it remains to deal with its connection.

Suppose we want to see the form on the / index / index or

Go to www / application / controllers / IndexConroller.php and connect our form as follows:

Next we need to send the form to display in our view the file. go to www / application / views / index / index.phtml and enter the output passed back form:

Now when you switch to the specified page, we will see this form.

The form is displayed, then the possibility of using Zend Form to verify the form data.

As we pointed out the field as a username and password are required - (setRequired (true) and addValidator ('NotEmpty')), then try to connect them to check.

To do this, we modify the code in www / application / controllers / IndexConroller.php the following:

Now we have a form that receives data and checks them for validity according to our preferences.

Post a Comment

Name: (Optional)
Email: (Optional, you can get an email if somebody replys your comments)*
Email me if somebody respons my comment below:
Enter Text
as Below:
(case insensitive, if hard to read, click the "get a new one" button)
* Your email address will not be shared with any third parties for any reason.
** Maximum 1000 charactors.