Permalink
Browse files

Update cookbook/symfony2/mastering-symfony2-forms-with-propel.markdown

Updated UniqueObject part to affect getDefaultOption() removal, which leads to Internal Server Error with previous example. Also shows how error message can be specified.

Commit and my comment:
propelorm/PropelBundle@1b0c49c#commitcomment-2187035
  • Loading branch information...
1 parent 4feee47 commit fa8cb29cc610d15c9b602bdac09b54f40093e1ce @zergu committed Nov 21, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 cookbook/symfony2/mastering-symfony2-forms-with-propel.markdown
View
7 cookbook/symfony2/mastering-symfony2-forms-with-propel.markdown
@@ -500,15 +500,18 @@ To use it is in a `validation.yml` file just add those few lines in your validat
{% highlight yaml %}
BundleNamespace\Model\User:
constraints:
- - Propel\PropelBundle\Validator\Constraints\UniqueObject: username
+ - Propel\PropelBundle\Validator\Constraints\UniqueObject:
+ fields: username
+ message: User already exists ({{ fields }}).
{% endhighlight %}
In order to validate the unicity of more than just one fields:
{% highlight yaml %}
BundleNamespace\Model\User:
constraints:
- - Propel\PropelBundle\Validator\Constraints\UniqueObject: [username, login]
+ - Propel\PropelBundle\Validator\Constraints\UniqueObject:
+ fields: [username, login]
{% endhighlight %}
As many validator of this type as you want can be used.

0 comments on commit fa8cb29

Please sign in to comment.