Skip to content

Commit f1329d0

Browse files
committed
[#6579] some tweaks
1 parent cec68bd commit f1329d0

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

book/forms.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,9 @@ large or whether you tried to submit text in a number field.
637637

638638
.. seealso::
639639

640-
To see how to use a service with dependencies to resolve ``validation_groups``
641-
checkout cookbook article :doc:`/cookbook/validation/validation-group-service-resolver`.
640+
To see how to use a service to resolve ``validation_groups`` dynamically
641+
read the :doc:`/cookbook/validation/validation-group-service-resolver`
642+
chapter in the cookbook.
642643

643644
.. index::
644645
single: Forms; Built-in field types

cookbook/map.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248

249249
* :doc:`/cookbook/validation/custom_constraint`
250250
* :doc:`/cookbook/validation/severity`
251-
* :doc:`/cookbook/validation/validation-group-service-resolver`
251+
* :doc:`/cookbook/validation/group_service_resolver`
252252

253253
* :doc:`/cookbook/web_server/index`
254254

cookbook/validation/validation-group-service-resolver.rst renamed to cookbook/validation/group_service_resolver.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
How to Dynamically Configure Validation Groups
22
==============================================
33

4-
Sometimes you need advanced logic to determine the validation groups. If this
4+
Sometimes you need advanced logic to determine the validation groups. If they
55
can't be determined by a simple callback, you can use a service. Create a
66
service that implements ``__invoke`` which accepts a ``FormInterface`` as a
77
parameter.
88

99
.. code-block:: php
1010
11+
// src/AppBundle/Validation/ValidationGroupResolver.php
1112
namespace AppBundle\Validation;
1213
1314
use Symfony\Component\Form\FormInterface;
@@ -42,15 +43,15 @@ Then in your form, inject the resolver and set it as the ``validation_groups``.
4243

4344
.. code-block:: php
4445
45-
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
46-
use Symfony\Component\Form\AbstractType
46+
// src/AppBundle/Form/MyClassType.php;
47+
namespace AppBundle\Form;
48+
4749
use AppBundle\Validator\ValidationGroupResolver;
50+
use Symfony\Component\Form\AbstractType
51+
use Symfony\Component\OptionsResolver\OptionsResolver;
4852
4953
class MyClassType extends AbstractType
5054
{
51-
/**
52-
* @var ValidationGroupResolver
53-
*/
5455
private $groupResolver;
5556
5657
public function __construct(ValidationGroupResolver $groupResolver)
@@ -59,7 +60,7 @@ Then in your form, inject the resolver and set it as the ``validation_groups``.
5960
}
6061
6162
// ...
62-
public function setDefaultOptions(OptionsResolverInterface $resolver)
63+
public function configureOptions(OptionsResolver $resolver)
6364
{
6465
$resolver->setDefaults(array(
6566
'validation_groups' => $this->groupResolver,

cookbook/validation/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Validation
66

77
custom_constraint
88
severity
9-
validation-group-service-resolver
9+
group_service_resolver

0 commit comments

Comments
 (0)