Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added required root element and namespaces to XML examples. #588

Merged
merged 1 commit into from

2 participants

Tobias Sjösten Ryan Weaver
Tobias Sjösten

This makes the examples more complete and less prone to errors when learning. It is also more consistent with the routing.xml examples.

Ryan Weaver weaverryan merged commit fe0aed5 into from
Ryan Weaver
Collaborator

Great, yes I agree - all examples should work by copying and pasting them. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 42 additions and 24 deletions.
  1. +42 −24 book/validation.rst
66 book/validation.rst
View
@@ -56,11 +56,17 @@ following:
.. code-block:: xml
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
- <class name="Acme\BlogBundle\Entity\Author">
- <property name="name">
- <constraint name="NotBlank" />
- </property>
- </class>
+ <?xml version="1.0" encoding="UTF-8" ?>
+ <constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd">
+
+ <class name="Acme\BlogBundle\Entity\Author">
+ <property name="name">
+ <constraint name="NotBlank" />
+ </property>
+ </class>
+ </constraint-mapping>
.. code-block:: php-annotations
@@ -324,17 +330,23 @@ constraint, have several configuration options available. Suppose that the
.. code-block:: xml
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
- <class name="Acme\BlogBundle\Entity\Author">
- <property name="gender">
- <constraint name="Choice">
- <option name="choices">
- <value>male</value>
- <value>female</value>
- </option>
- <option name="message">Choose a valid gender.</option>
- </constraint>
- </property>
- </class>
+ <?xml version="1.0" encoding="UTF-8" ?>
+ <constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd">
+
+ <class name="Acme\BlogBundle\Entity\Author">
+ <property name="gender">
+ <constraint name="Choice">
+ <option name="choices">
+ <value>male</value>
+ <value>female</value>
+ </option>
+ <option name="message">Choose a valid gender.</option>
+ </constraint>
+ </property>
+ </class>
+ </constraint-mapping>
.. code-block:: php-annotations
@@ -389,14 +401,20 @@ options can be specified in this way.
.. code-block:: xml
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
- <class name="Acme\BlogBundle\Entity\Author">
- <property name="gender">
- <constraint name="Choice">
- <value>male</value>
- <value>female</value>
- </constraint>
- </property>
- </class>
+ <?xml version="1.0" encoding="UTF-8" ?>
+ <constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd">
+
+ <class name="Acme\BlogBundle\Entity\Author">
+ <property name="gender">
+ <constraint name="Choice">
+ <value>male</value>
+ <value>female</value>
+ </constraint>
+ </property>
+ </class>
+ </constraint-mapping>
.. code-block:: php-annotations
Something went wrong with that request. Please try again.