File tree 1 file changed +8
-6
lines changed
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ that constructor with no arguments::
39
39
40
40
use Symfony\Component\Form\AbstractType;
41
41
use Acme\DemoBundle\Entity\Blog;
42
+ use Symfony\Component\OptionsResolver\OptionsResolverInterface;
42
43
43
44
class BlogType extends AbstractType
44
45
{
@@ -50,11 +51,11 @@ that constructor with no arguments::
50
51
}
51
52
// ...
52
53
53
- public function getDefaultOptions( )
54
+ public function setDefaultOptions(OptionsResolverInterface $resolver )
54
55
{
55
- return array(
56
+ $resolver->setDefaults( array(
56
57
'empty_data' => new Blog($this->someDependency),
57
- );
58
+ )) ;
58
59
}
59
60
}
60
61
@@ -71,14 +72,15 @@ if it is needed.
71
72
72
73
The closure must accept a ``FormInterface `` instance as the first argument::
73
74
75
+ use Symfony\Component\OptionsResolver\OptionsResolverInterface;
74
76
use Symfony\Component\Form\FormInterface;
75
77
// ...
76
78
77
- public function getDefaultOptions( )
79
+ public function setDefaultOptions(OptionsResolverInterface $resolver )
78
80
{
79
- return array(
81
+ $resolver->setDefaults( array(
80
82
'empty_data' => function (FormInterface $form) {
81
83
return new Blog($form->get('title')->getData());
82
84
},
83
- );
85
+ )) ;
84
86
}
You can’t perform that action at this time.
0 commit comments