@@ -470,13 +470,17 @@ you'll need to specify which validation group(s) your form should use::
470470 'validation_groups' => array('registration'),
471471 ))->add(...);
472472
473+ .. versionadded :: 2.7
474+ The ``configureOptions() `` method was introduced in Symfony 2.7. Previously,
475+ the method was called ``setDefaultOptions() ``.
476+
473477If you're creating :ref: `form classes <book-form-creating-form-classes >` (a
474- good practice), then you'll need to add the following to the ``setDefaultOptions () ``
478+ good practice), then you'll need to add the following to the ``configureOptions () ``
475479method::
476480
477- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
481+ use Symfony\Component\OptionsResolver\OptionsResolver ;
478482
479- public function setDefaultOptions(OptionsResolverInterface $resolver)
483+ public function configureOptions(OptionsResolver $resolver)
480484 {
481485 $resolver->setDefaults(array(
482486 'validation_groups' => array('registration'),
@@ -498,9 +502,9 @@ Disabling Validation
498502Sometimes it is useful to suppress the validation of a form altogether. For
499503these cases you can set the ``validation_groups `` option to ``false ``::
500504
501- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
505+ use Symfony\Component\OptionsResolver\OptionsResolver ;
502506
503- public function setDefaultOptions(OptionsResolverInterface $resolver)
507+ public function configureOptions(OptionsResolver $resolver)
504508 {
505509 $resolver->setDefaults(array(
506510 'validation_groups' => false,
@@ -524,10 +528,10 @@ If you need some advanced logic to determine the validation groups (e.g.
524528based on submitted data), you can set the ``validation_groups `` option
525529to an array callback::
526530
527- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
531+ use Symfony\Component\OptionsResolver\OptionsResolver ;
528532
529533 // ...
530- public function setDefaultOptions(OptionsResolverInterface $resolver)
534+ public function configureOptions(OptionsResolver $resolver)
531535 {
532536 $resolver->setDefaults(array(
533537 'validation_groups' => array(
@@ -544,10 +548,10 @@ You can also define whole logic inline by using a ``Closure``::
544548
545549 use Acme\AcmeBundle\Entity\Client;
546550 use Symfony\Component\Form\FormInterface;
547- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
551+ use Symfony\Component\OptionsResolver\OptionsResolver ;
548552
549553 // ...
550- public function setDefaultOptions(OptionsResolverInterface $resolver)
554+ public function configureOptions(OptionsResolver $resolver)
551555 {
552556 $resolver->setDefaults(array(
553557 'validation_groups' => function(FormInterface $form) {
@@ -567,10 +571,10 @@ of the entity as well you have to adjust the option as follows::
567571
568572 use Acme\AcmeBundle\Entity\Client;
569573 use Symfony\Component\Form\FormInterface;
570- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
574+ use Symfony\Component\OptionsResolver\OptionsResolver ;
571575
572576 // ...
573- public function setDefaultOptions(OptionsResolverInterface $resolver)
577+ public function configureOptions(OptionsResolver $resolver)
574578 {
575579 $resolver->setDefaults(array(
576580 'validation_groups' => function(FormInterface $form) {
@@ -1090,9 +1094,9 @@ the choice is ultimately up to you.
10901094 good idea to explicitly specify the ``data_class `` option by adding the
10911095 following to your form type class::
10921096
1093- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
1097+ use Symfony\Component\OptionsResolver\OptionsResolver ;
10941098
1095- public function setDefaultOptions(OptionsResolverInterface $resolver)
1099+ public function configureOptions(OptionsResolver $resolver)
10961100 {
10971101 $resolver->setDefaults(array(
10981102 'data_class' => 'AppBundle\Entity\Task',
@@ -1321,7 +1325,7 @@ create a form class so that a ``Category`` object can be modified by the user::
13211325
13221326 use Symfony\Component\Form\AbstractType;
13231327 use Symfony\Component\Form\FormBuilderInterface;
1324- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
1328+ use Symfony\Component\OptionsResolver\OptionsResolver ;
13251329
13261330 class CategoryType extends AbstractType
13271331 {
@@ -1330,7 +1334,7 @@ create a form class so that a ``Category`` object can be modified by the user::
13301334 $builder->add('name');
13311335 }
13321336
1333- public function setDefaultOptions(OptionsResolverInterface $resolver)
1337+ public function configureOptions(OptionsResolver $resolver)
13341338 {
13351339 $resolver->setDefaults(array(
13361340 'data_class' => 'AppBundle\Entity\Category',
@@ -1756,13 +1760,13 @@ that all un-rendered fields are output.
17561760
17571761The CSRF token can be customized on a form-by-form basis. For example::
17581762
1759- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
1763+ use Symfony\Component\OptionsResolver\OptionsResolver ;
17601764
17611765 class TaskType extends AbstractType
17621766 {
17631767 // ...
17641768
1765- public function setDefaultOptions(OptionsResolverInterface $resolver)
1769+ public function configureOptions(OptionsResolver $resolver)
17661770 {
17671771 $resolver->setDefaults(array(
17681772 'data_class' => 'AppBundle\Entity\Task',
0 commit comments