Permalink
Browse files

[#2415] Updating empty_data document for 2.1 changes

  • Loading branch information...
1 parent 17eef6a commit 0d62bfc35c37d8c08a1f7665da99b041a35a45ee @weaverryan weaverryan committed Apr 4, 2013
Showing with 8 additions and 6 deletions.
  1. +8 −6 cookbook/form/use_empty_data.rst
@@ -39,6 +39,7 @@ that constructor with no arguments::
use Symfony\Component\Form\AbstractType;
use Acme\DemoBundle\Entity\Blog;
+ use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class BlogType extends AbstractType
{
@@ -50,11 +51,11 @@ that constructor with no arguments::
}
// ...
- public function getDefaultOptions()
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
{
- return array(
+ $resolver->setDefaults(array(
'empty_data' => new Blog($this->someDependency),
- );
+ ));
}
}
@@ -71,14 +72,15 @@ if it is needed.
The closure must accept a ``FormInterface`` instance as the first argument::
+ use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\FormInterface;
// ...
- public function getDefaultOptions()
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
{
- return array(
+ $resolver->setDefaults(array(
'empty_data' => function (FormInterface $form) {
return new Blog($form->get('title')->getData());
},
- );
+ ));
}

0 comments on commit 0d62bfc

Please sign in to comment.