Problems with setRequired and ZendForm

For programming and general questions on Zend Framework

Problems with setRequired and ZendForm

Postby viniciuswebdev on Tue Nov 20, 2012 2:19 am

Hello!

My form is working fine, but the setRequired not working, he is submitting empty values...

Help? Many Thanks !!!

Code: Select all
<?php

class Application_Form_Login extends Zend_Form
{

    public function init()
    {
               
       $login = new Zend_Form_Element_Text('login_user');
       $login->setRequired(true)
               ->setAttribs(array('class'=>'input-block-level'))
             ->setLabel('nome de usuário:');
              
       $password = new Zend_Form_Element_Password('password_user');
       $password->setRequired(true)
                ->setAttribs(array('class'=>'input-block-level'))
                ->setLabel('senha:');
       
      $submit = new Zend_Form_Element_Submit('Acessar');
      $submit->setAttrib('class', 'btn btn-large btn-success');
       
       $this->addElements(array($login, $password, $submit));
       
    }
}
viniciuswebdev
 
Posts: 2
Joined: Tue Nov 20, 2012 2:14 am

Re: Problems with setRequired and ZendForm

Postby us2rn4m2 on Tue Nov 20, 2012 8:55 am

Hello,

For ZF1

In your Controller add:

Code: Select all
$request = $this->getRequest();

if($request->isPost()) {
      if($form->isValid($request->getPost())) {
              your instruction ....
                 
}
us2rn4m2
 
Posts: 49
Joined: Mon Jun 18, 2012 12:41 am

Re: Problems with setRequired and ZendForm

Postby viniciuswebdev on Tue Nov 20, 2012 1:04 pm

working! many thanks!!
viniciuswebdev
 
Posts: 2
Joined: Tue Nov 20, 2012 2:14 am


Return to Zend Framework

Who is online

Users browsing this forum: matt4257, Yahoo [Bot] and 14 guests