Creating form in Zend Framework in Netbeans IDE

My another work in Zend Framework is forms. In this post I show You how creating form with several form elements.
Begin with open Netbeans IDE and selecting from main menu File->New Project.

In New Project window in Categories section select PHP and in Projects section select PHP Application and click on Next button.

In Project Name field write MyForm. It is your project’s name.  Click on Next button.

In another step in Project URL field add to the end of path word public. Click on Next button.

From list of PHP Frameworks select Zend PHP Web Framework and click on Finish button.

In Projects window in Netbeans, You see structure of Your project.

Open .htaccess file from public node and paste into it on the top this code:

SetEnv APPLICATION_ENV development
DirectoryIndex index.php

Owing to You may display errors information in displaying websites. Save this file and right click on project node and select Zend->Run Command.

In Run Zend window write in Filter field enable layout and click on Run button.

From application/layouts/scripts open layout.phtml file. Paste into it this code:

 
 
    MyForm
        
 

        

In this moment You may create form. Right click on project node and choose Zend->Run Command.

In Run Zend window in Filter field write create form and in Parameters field write name of form: My. Click on Run button.

Open new creating file in applications/forms node(My.php).

Paste into it in init method this code:

$text1=new Zend_Form_Element_Text('animal_name',array('label'=>'Animal name:'));
$this->addElement($text1);
$select1=new Zend_Form_Element_Select('animal_group',
              array('label'=>'Select group of animal:',
                    'multiOptions'=>array('mammals'=>'Mammals','reptiles'=>'Reptiles')));
$this->addElement($select1);
$submit1=new Zend_Form_Element_Submit('animal_submit',array('label'=>'Send data'));
$this->addElement$submit1);

Save My.php file.

Open in application/controllers node indexController.php file. Paste into indexAction method code:

 $this->view->form = new Application_Form_My();

Save file.

Open view for form( file index.phtml in application/views/scripts/index node ).

Paste into this file code:

My form


If You call only form variable for current object You see all form. Run application and see result: