Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d62bfc

Browse files
committed
[#2415] Updating empty_data document for 2.1 changes
1 parent17eef6a commit0d62bfc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

‎cookbook/form/use_empty_data.rst

Lines changed: 8 additions & 6 deletions
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 functiongetDefaultOptions()
54+
public functionsetDefaultOptions(OptionsResolverInterface $resolver)
5455
{
55-
returnarray(
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 functiongetDefaultOptions()
79+
public functionsetDefaultOptions(OptionsResolverInterface $resolver)
7880
{
79-
returnarray(
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)

[8]ページ先頭

©2009-2025 Movatter.jp