This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » sfValidatorAnd inner error messages
sfValidatorAnd inner error messages [message #103142] Tue, 27 July 2010 18:01
chriso  is currently offline chriso
Messages: 3
Registered: July 2010
Junior Member
Hello. I am doing form validation (with a sfFormSymfony)

I am using an sfValidatorAnd validator, and I am having trouble getting the appropriate errors rendered.

Here's what I have.

        $this->setValidators(array(
            'username' =>
                new sfValidatorAnd(
                    array(
                        new sfValidatorString(array(), array('required'=>'Username is required).')),
                        new sfValidatorRegex(
                            array('pattern'=>'/^[a-zA-Z]+$/'),
                            array('invalid'=>'Usernames can only contain letters (inner error.')
                        )
                    )
                )
        ));
        $this->getValidator('username')->setMessage('invalid',"Username is invalid (outer error).");


So, when this widget fails on the sfValidatorRegex, I want (sfFormField)->renderError() to render the inner error:
'Usernames can only contain letters (inner error.').' instead of the outer error.

Is this possible?

Thanks.

[Updated on: Tue, 27 July 2010 18:02]

Previous Topic:Symfony forms: Internationalization
Next Topic:symfony doctrine:build --all with 2 connection
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software