First of all, interface :
We will add a method "isAlreadyRegistered" to your form, to know if there is
an error about already registerred and use it in actions :
public function executeRegister(sfWebRequest $request)
{
$this->form = new myForm();
$this->form->bind(...);
if ($this->form->isValid())
{
$this->form->save();
// your stuff
}
else
{
if ($this->form->isAlreadyRegistered())
{
return $this->redirect(...);
}
}
// your stuff
}
Finally, define the method :
public function isAlreadyRegistered()
{
// access $this->errorSchema and find your error
}
Must investigate about how to retrieve errors on a field, and then return
true or false. Don't have the answer for this.
Look at this : http://www.symfony-project.org/api/1_4/sfValidatorErrorSchema-
can be accessed like an array, so test with :
var_dump($this->errorSchema['email']); and see what you get
Alexandre
2009/12/15 Julien L <[email protected]>
> Hi,
>
> I would like to redirect the user to an other page when the
> "matricule" typed already exists instead of my invalid message
> 'L'utilisateur à déjà été créé'.
>
> //BaseKiosquePatientForm.class.php
>
> $this->validatorSchema->setPostValidator(
> new sfValidatorDoctrineUnique(array(
> 'model' => 'KiosquePatient',
> 'column' => array('matricule')
> ),array(
> 'invalid' => 'L\'utilisateur à déjà été créé'
> )
> )
> );
>
> Anyone have an idea?
>
> Thanks
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "symfony users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<symfony-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en.
>
>
>
--
Alexandre Salomé
http://alexandre-salome.fr
--
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en.