Skip to content

Commit 1d3a10c

Browse files
committed
minor #7836 Better explain how to enable the validation component and its annotations (javiereguiluz)
This PR was squashed before being merged into the 2.7 branch (closes #7836). Discussion ---------- Better explain how to enable the validation component and its annotations This fixes #7797. Commits ------- dc5ff52 Better explain how to enable the validation component and its annotations
2 parents cbb8346 + dc5ff52 commit 1d3a10c

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

validation.rst

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,42 @@ Configuration
212212
-------------
213213

214214
Before using the Symfony validator, make sure it's enabled in the main config
215-
file. Besides, if you plan to use annotations to configure validation, make sure
216-
that the ``enable_annotations`` option is ``true``:
215+
file:
216+
217+
.. configuration-block::
218+
219+
.. code-block:: yaml
220+
221+
# app/config/config.yml
222+
framework:
223+
validation: { enabled: true }
224+
225+
.. code-block:: xml
226+
227+
<!-- app/config/config.xml -->
228+
<?xml version="1.0" encoding="UTF-8" ?>
229+
<container xmlns="http://symfony.com/schema/dic/services"
230+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
231+
xmlns:framework="http://symfony.com/schema/dic/symfony"
232+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
233+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
234+
235+
<framework:config>
236+
<framework:validation enabled="true" />
237+
</framework:config>
238+
</container>
239+
240+
.. code-block:: php
241+
242+
// app/config/config.php
243+
$container->loadFromExtension('framework', array(
244+
'validation' => array(
245+
'enabled' => true,
246+
),
247+
));
248+
249+
Besides, if you plan to use annotations to configure validation, replace the
250+
previous configuration by the following:
217251

218252
.. configuration-block::
219253

0 commit comments

Comments
 (0)