Skip to content

Commit 0d62bfc

Browse files
committed
[#2415] Updating empty_data document for 2.1 changes
1 parent 17eef6a commit 0d62bfc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cookbook/form/use_empty_data.rst

+8-6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ that constructor with no arguments::
3939

4040
use Symfony\Component\Form\AbstractType;
4141
use Acme\DemoBundle\Entity\Blog;
42+
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
4243

4344
class BlogType extends AbstractType
4445
{
@@ -50,11 +51,11 @@ that constructor with no arguments::
5051
}
5152
// ...
5253

53-
public function getDefaultOptions()
54+
public function setDefaultOptions(OptionsResolverInterface $resolver)
5455
{
55-
return array(
56+
$resolver->setDefaults(array(
5657
'empty_data' => new Blog($this->someDependency),
57-
);
58+
));
5859
}
5960
}
6061

@@ -71,14 +72,15 @@ if it is needed.
7172

7273
The closure must accept a ``FormInterface`` instance as the first argument::
7374

75+
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
7476
use Symfony\Component\Form\FormInterface;
7577
// ...
7678

77-
public function getDefaultOptions()
79+
public function setDefaultOptions(OptionsResolverInterface $resolver)
7880
{
79-
return array(
81+
$resolver->setDefaults(array(
8082
'empty_data' => function (FormInterface $form) {
8183
return new Blog($form->get('title')->getData());
8284
},
83-
);
85+
));
8486
}

0 commit comments

Comments
 (0)