Thanks Alex!,
I tried the sfValidatorDoctrineUnique validator and work's good, i just add
to the following method to my /lib/AccountsForm.class.php

$this->validatorSchema->setPostValidator(new
sfValidatorDoctrineUnique(array('model' => 'Accounts', 'column' =>
array('email')),array('invalid'=>'Ya esta registrado el %column%
ingresado.')));

It's very helpful. But the only problem that i still having, it's that the
login field (that the user also input) it's the key of the table. So
Doctrine and Mysql don't allow duplicate keys, i want to resolve it using
the same Validator [1] but it don't work. Instead of show me a message that
the "login" already exists, symfony generates an error "SQLSTATE[23000]:
Integrity constraint violation: 1062 Duplicate entry 'duplicateValue' for
key 1"

[1] $this->validatorSchema->setPostValidator(new
sfValidatorDoctrineUnique(array('model' => 'Accounts', 'column' =>
array('email','login')),array('invalid'=>'Ya esta registrado el %column%
ingresado.')));

I will try to solve it and how to solve.

On 18 November 2010 15:50, Alex Pilon <[email protected]> wrote:

> You can set an index on doctrine models and make the index unique..
>
>
> http://www.doctrine-project.org/documentation/manual/1_0/en/defining-models:indexes:index-options
>
>
> <http://www.doctrine-project.org/documentation/manual/1_0/en/defining-models:indexes:index-options>If
> you want to make some sort of validator that checks to see if what you typed
> already exists, there is some validator out there called
> sfValidatorUsernameUnique or something which you can look at and probably
> make it work for you. I think there is an email one too. Check the API.
>
> Word
>
> On Thu, Nov 18, 2010 at 12:43, Ardison Nicolas <[email protected]>wrote:
>
>> Hi folks,
>> I have a table table with Doctrine where i have an numeric id as a key and
>> an email, the email must be unique (as the key), i know that i can write the
>> code to do it at the create method when i insert the data in the SQL. But i
>> want to know if doctrine have something to do it editing the base of the
>> model or of the form in the lib.
>>
>> Cheers!
>>
>> --
>> Nicolas G. Ardison
>> [email protected]
>>
>> Antes de imprimir este mensaje, asegúrese de que es necesario. El medio
>> ambiente está en nuestras manos.
>> Before printing, think about the environment.
>>
>>  --
>> If you want to report a vulnerability issue on symfony, please send it to
>> security at symfony-project.com
>>
>> 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
>>
>
>
>
> --
> Alex Pilon
> (613) 608-1480
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> 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
>



-- 
Nicolas G. Ardison
[email protected]

Antes de imprimir este mensaje, asegúrese de que es necesario. El medio
ambiente está en nuestras manos.
Before printing, think about the environment.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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

Reply via email to