Apply for Zend Framework Certification Training

Zend Framework 2




Step 1 Create an form 			Form\RegistrationForm.php

<?php
namespace Movie\Form;
use Zend\Form\Form;

class RegistrationForm extends Form
{
	public function __construct()
	{
		parent::__construct('Movie');
		$this->add(array('name'=>'id','type'=>'hidden'));
		$this->add(array('name'=>'name','type'=>'text','options'=>array('label'=>'Employee Name :'),
                                                                                                          'attributes'=>array('id'=>'name')));
		$this->add(array('name'=>'address','type'=>'text','options'=>array('label'=>'Employee Address :'),
                                                                                                          'attributes'=>array('id'=>'address')));
		$this->add(array('name'=>'submit','type'=>'submit','attributes'=>array('value'=>'Register', 'id'=>'btn')));
	}
}

Step 2     Respective file of Action View\movie\register.phtml
<script>
	$(document).ready(function(){
		$("#btn").click(function(e){
			name	= $("#name").val();
			address	= $("#address").val();
			datastring="name="+name+"&address="+address;
			$.ajax({
				type:'POST',
				data:datastring,
				url:'http://localhost:8000/movie/register',
				success:function(data){
						$("#name").val("");
						$("#address").val("");
						$("#response").load("http://localhost:8000/movie/listall");
					}
				});
			return false;
		});
		
	});
</script>


<?php 
	echo $this->form()->openTag($register);
	echo $this->formHidden($register->get('id'));
	echo $this->formRow($register->get('name'));
	echo "<br>";
	echo $this->formRow($register->get('address'));
	echo "<br>";
	echo $this->formSubmit($register->get('submit'));
	echo $this->form()->closeTag();
?>
<div id="response"></div>
                                    

< Redirect in jquery Php Questions Part 2 >



Ask a question



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


Back to Top