Good afternoon! I have a problem with validation in symfony.
archive: C:\xampplite\htdocs\portalcepai\lib\form\LoginForm.class <?php class LoginForm extends sfForm { public function configure() { $this->setWidgets(array( 'username' => new sfWidgetFormInput(), 'password' => new sfWidgetFormInputPassword() )); $this->widgetSchema->setLabels(array( 'username' => 'Usuário', 'password' => 'Senha', )); $this->setValidators(array( 'username' => new sfValidatorString(array('required' => true)), 'password' => new sfValidatorString(array('required' => true)), )); } } template:-> loginSucess.php <form action="<?php echo url_for('login/login') ?>" method="POST"> <?php echo $form ?> <input type="submit" value="Logar"/> </form> My action method responsable for login public function executeLogin(sfWebRequest $request) { if ($this->getRequest()->getMethod() != sfRequest::POST) { // display the form $this->getRequest()->setAttribute('referer', $this->getRequest()- >getReferer()); $this->form = new LoginForm(); } else { // handle the form submission $username = $this->getRequestParameter('username'); $password = md5($this->getRequestParameter('password')); $this->forward404Unless($usuario = Doctrine::getTable('Usuario')- >findOneByUsername($username), sprintf('O usuário (%s) não existe .', $username)); //$usuario = Doctrine::getTable('Usuario')- >findOneByUsername($username); // password is OK? if ($usuario->password == $password) { //Inclui na sessão os dados do usuário $this->getUser()->setAuthenticated(true); $this->getUser()->addCredential($usuario->perfil); //nome atributo, valor, valor padrão caso esteja nulo $this->getUser()->setAttribute('id', $usuario->id); $this->getUser()->setAttribute('username', $usuario- >username); $this->getUser()->setAttribute('password', $usuario- >password); $this->getUser()->setAttribute('perfil', $usuario->perfil); $this->getUser()->setAttribute('email', $usuario->email); $this->redirect('home/index'); //return $this->redirect($this->getRequestParameter('referer', '@homepage')); } else { //password incorreto $this->forward404(" Senha inválida. "); } } } So, when I put blank the fields username or password, nothing be, the form is processed normally, without validation. What the problem?? Thanks. Rodrigo -- You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.