Apply for Zend Framework Certification Training

Zend Framework 2

Step 1 create A form
namespace Application\form;
use Zend\Form\Form;

class MovieForm extends form
    public function __construct($name = null) 
        $this->setAttribute('method', 'post');
Step 2 create view file

<table border="0" width="500" align="center">
<?php $form = $this->movieform; echo  $this->form()->opentag($form); ?>
    <tr><td> First name     </td><td><?php   echo  $this->formRow($form->get('name')); ?></td></tr>
    <tr><td> Email          </td><td><?php   echo  $this->formRow($form->get('email')); ?></td></tr>
    <tr><td colspan="2" align="center"><?php   echo  $this->formSubmit($form->get('submit')); ?></td></tr>
<?php   echo  $this->form()->closeTag();    ?>
Step 4 Add Code in controller

public function registrationformAction()
        $movieform = new MovieForm();
        $request = $this->getRequest();
        if ($request->isPost()) {
                $request = $request->getPost();
        return new ViewModel(array('movieform'=>$movieform));

Step 5  Add code in Model 

 public function savemovie($request)
        $data = array('name' => $request['name'],'email'=> $request['email']);


< List of mysql data usng php in zend framework 2 Directory Structure Of ZendFramework2 >

Ask a question

  • Question:
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question

Back to Top