views:

53

answers:

0

Hello,

I have a form where the primary-key must be filled by the user. But if he enters a value existing, I have the page with doctrine error 'Integrity constraint violation: 1062 Duplicate entry'.

I want to make an error message as the other key with

$form['myKey']->renderError()

I have tried to use sfValidatorDoctrineChoice :

$this->validatorSchema['nud'] = new sfValidatorAnd(array(
    new sfValidatorString(array(
        'max_length' => 18,
        'required' => true)),
    new sfValidatorDoctrineUnique(array(
        'model' => 'locataire',
        'column' => 'nud',
        'primary_key' => 'nud',
        'throw_global_error' => true))));

But it doesn't work. I have no error and the Doctrine error page is loaded.