Skip to content

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

Merged
merged 1 commit into from Nov 21, 2012
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.
Something went wrong with that request. Please try again.