2

I have a field domain_name in my form which must be unique. So I have a unique validator like this :

$this->validatorSchema->setPostValidator(
            new sfValidatorDoctrineUnique(
            array(
              'model' => 'Domain', 
              'column' => array('domain_name')
            ), 
            array('invalid' => 'This domain already exist.')));

But this validator does not recognize accents. For instance, the both domain names, example.fr and éxample.fr, are the same for him, and so it throws the error.

How can I do to make the difference between both (with accents and without accents) ?

j0k
  • 22,600
  • 28
  • 79
  • 90
Goku
  • 2,157
  • 2
  • 16
  • 31
  • 2
    Check your sql query when submitted the form to see the one which check uniqueness for the column. Run it on phpmyadmin and see if you get something. It might be a problem on your mysql instead of doctrine (see [this one](http://stackoverflow.com/q/8024092/569101)). – j0k May 21 '13 at 15:38
  • How can I do to see the query when I submit the form ? In the symfony toolbar I do not see it... – Goku May 22 '13 at 10:51
  • 1
    You can take a look into the log file (`/log/frontend_dev.log`) or by [enabling log query in MySQL](http://stackoverflow.com/q/6479107/569101). – j0k May 22 '13 at 11:19
  • Thank you very much @j0k, I have change the collation of my table and it works great :) – Goku May 22 '13 at 15:13
  • J'ai vu que tu étais français, si j'avais su j'aurais moins galéré à parler anglais :) – Goku May 22 '13 at 15:26
  • Etant donné que StackOverflow touche un public *international*, c'est mieux de poser ses questions en anglais pour que tout le monde puisse la comprendre et que cela puisse aider n'importe qui :) – j0k May 22 '13 at 16:06
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/30463/discussion-between-panpelope-and-j0k) – Goku May 23 '13 at 07:04

1 Answers1

0

If, like j0k says it's not a SQL issue, then you may want to build your own validator following this guideline: http://symfony.com/legacy/doc/more-with-symfony/1_4/en/05-Custom-Widgets-and-Validators#chapter_05_building_a_simple_widget_and_validator and using regex to catch accents.

DevAntoine
  • 1,932
  • 19
  • 24