Zend Form Registration with -
i new in zend.
have tried create registration form in zend.
have array of form return false.
it returns me every time bye .
don't know why???
it's simple: first, create registration form under application/forms or use zend tool
zf enable form zf create form registration
this create file under application/forms entitled registration.php
class application_form_registration extends zend_form { public function init() { $firstname = $this->createelement('text','firstname'); $firstname->setlabel('first name:') ->setrequired(false); $lastname = $this->createelement('text','lastname'); $lastname->setlabel('last name:') ->setrequired(false); $email = $this->createelement('text','email'); $email->setlabel('email: *') ->setrequired(false); $username = $this->createelement('text','username'); $username->setlabel('username: *') ->setrequired(true); $password = $this->createelement('password','password'); $password->setlabel('password: *') ->setrequired(true); $confirmpassword = $this->createelement('password','confirmpassword'); $confirmpassword->setlabel('confirm password: *') ->setrequired(true); $register = $this->createelement('submit','register'); $register->setlabel('sign up') ->setignore(true); $this->addelements(array( $firstname, $lastname, $email, $username, $password, $confirmpassword, $register )); } }
this simple form limited validation (only validation fields required!)
then have render form in view using corresponding action: example in usercontroller add action called
public function registeraction() { //send form view (register) $userform = new application_form_registration(); $this->view->form = $userform; //check if user entered data , submitted if ($this->getrequest()->ispost()) { //check form validation if not valid error message appear under every required field if ($userform->isvalid($this->getrequest()->getparams())) { //send data model store $usermodel = new application_model_user(); $userid = $usermodel->adduser($userform->getvalues()); } } }
the last two, render form in view called register using
<?= $this->form ?>
and add method in model called adduser() handle insertion of data database
Comments
Post a Comment