@@ -175,7 +175,7 @@ That's it! Just three lines are needed to render the complete form:
175
175
Renders all the fields, which includes the field element itself, a label
176
176
and any validation error messages for the field.
177
177
178
- ``form_end() ``
178
+ ``form_end(form ) ``
179
179
Renders the end tag of the form and any fields that have not
180
180
yet been rendered, in case you rendered each field yourself. This is useful
181
181
for rendering hidden fields and taking advantage of the automatic
@@ -470,13 +470,17 @@ you'll need to specify which validation group(s) your form should use::
470
470
'validation_groups' => array('registration'),
471
471
))->add(...);
472
472
473
+ .. versionadded :: 2.7
474
+ The ``configureOptions() `` method was introduced in Symfony 2.7. Previously,
475
+ the method was called ``setDefaultOptions() ``.
476
+
473
477
If 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 () ``
475
479
method::
476
480
477
- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
481
+ use Symfony\Component\OptionsResolver\OptionsResolver ;
478
482
479
- public function setDefaultOptions(OptionsResolverInterface $resolver)
483
+ public function configureOptions(OptionsResolver $resolver)
480
484
{
481
485
$resolver->setDefaults(array(
482
486
'validation_groups' => array('registration'),
@@ -498,9 +502,9 @@ Disabling Validation
498
502
Sometimes it is useful to suppress the validation of a form altogether. For
499
503
these cases you can set the ``validation_groups `` option to ``false ``::
500
504
501
- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
505
+ use Symfony\Component\OptionsResolver\OptionsResolver ;
502
506
503
- public function setDefaultOptions(OptionsResolverInterface $resolver)
507
+ public function configureOptions(OptionsResolver $resolver)
504
508
{
505
509
$resolver->setDefaults(array(
506
510
'validation_groups' => false,
@@ -524,10 +528,10 @@ If you need some advanced logic to determine the validation groups (e.g.
524
528
based on submitted data), you can set the ``validation_groups `` option
525
529
to an array callback::
526
530
527
- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
531
+ use Symfony\Component\OptionsResolver\OptionsResolver ;
528
532
529
533
// ...
530
- public function setDefaultOptions(OptionsResolverInterface $resolver)
534
+ public function configureOptions(OptionsResolver $resolver)
531
535
{
532
536
$resolver->setDefaults(array(
533
537
'validation_groups' => array(
@@ -544,10 +548,10 @@ You can also define whole logic inline by using a ``Closure``::
544
548
545
549
use Acme\AcmeBundle\Entity\Client;
546
550
use Symfony\Component\Form\FormInterface;
547
- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
551
+ use Symfony\Component\OptionsResolver\OptionsResolver ;
548
552
549
553
// ...
550
- public function setDefaultOptions(OptionsResolverInterface $resolver)
554
+ public function configureOptions(OptionsResolver $resolver)
551
555
{
552
556
$resolver->setDefaults(array(
553
557
'validation_groups' => function(FormInterface $form) {
@@ -567,10 +571,10 @@ of the entity as well you have to adjust the option as follows::
567
571
568
572
use Acme\AcmeBundle\Entity\Client;
569
573
use Symfony\Component\Form\FormInterface;
570
- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
574
+ use Symfony\Component\OptionsResolver\OptionsResolver ;
571
575
572
576
// ...
573
- public function setDefaultOptions(OptionsResolverInterface $resolver)
577
+ public function configureOptions(OptionsResolver $resolver)
574
578
{
575
579
$resolver->setDefaults(array(
576
580
'validation_groups' => function(FormInterface $form) {
@@ -1090,9 +1094,9 @@ the choice is ultimately up to you.
1090
1094
good idea to explicitly specify the ``data_class `` option by adding the
1091
1095
following to your form type class::
1092
1096
1093
- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
1097
+ use Symfony\Component\OptionsResolver\OptionsResolver ;
1094
1098
1095
- public function setDefaultOptions(OptionsResolverInterface $resolver)
1099
+ public function configureOptions(OptionsResolver $resolver)
1096
1100
{
1097
1101
$resolver->setDefaults(array(
1098
1102
'data_class' => 'AppBundle\Entity\Task',
@@ -1321,7 +1325,7 @@ create a form class so that a ``Category`` object can be modified by the user::
1321
1325
1322
1326
use Symfony\Component\Form\AbstractType;
1323
1327
use Symfony\Component\Form\FormBuilderInterface;
1324
- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
1328
+ use Symfony\Component\OptionsResolver\OptionsResolver ;
1325
1329
1326
1330
class CategoryType extends AbstractType
1327
1331
{
@@ -1330,7 +1334,7 @@ create a form class so that a ``Category`` object can be modified by the user::
1330
1334
$builder->add('name');
1331
1335
}
1332
1336
1333
- public function setDefaultOptions(OptionsResolverInterface $resolver)
1337
+ public function configureOptions(OptionsResolver $resolver)
1334
1338
{
1335
1339
$resolver->setDefaults(array(
1336
1340
'data_class' => 'AppBundle\Entity\Category',
@@ -1756,13 +1760,13 @@ that all un-rendered fields are output.
1756
1760
1757
1761
The CSRF token can be customized on a form-by-form basis. For example::
1758
1762
1759
- use Symfony\Component\OptionsResolver\OptionsResolverInterface ;
1763
+ use Symfony\Component\OptionsResolver\OptionsResolver ;
1760
1764
1761
1765
class TaskType extends AbstractType
1762
1766
{
1763
1767
// ...
1764
1768
1765
- public function setDefaultOptions(OptionsResolverInterface $resolver)
1769
+ public function configureOptions(OptionsResolver $resolver)
1766
1770
{
1767
1771
$resolver->setDefaults(array(
1768
1772
'data_class' => 'AppBundle\Entity\Task',
0 commit comments