From 3a0b4a37855fb6af5c9a41e24fdc00f0ad7c7537 Mon Sep 17 00:00:00 2001 From: Kevin Archer Date: Thu, 8 Nov 2012 00:26:17 -0500 Subject: [PATCH 1/5] Update cookbook/form/create_form_type_extension.rst Added missing options parameter --- cookbook/form/create_form_type_extension.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cookbook/form/create_form_type_extension.rst b/cookbook/form/create_form_type_extension.rst index 116992d1280..5c7e974c24c 100644 --- a/cookbook/form/create_form_type_extension.rst +++ b/cookbook/form/create_form_type_extension.rst @@ -219,8 +219,9 @@ it in the view:: * * @param \Symfony\Component\Form\FormView $view * @param \Symfony\Component\Form\FormInterface $form + * @param array $options */ - public function buildView(FormView $view, FormInterface $form) + public function buildView(FormView $view, FormInterface $form, array $options) { if (array_key_exists('image_path', $options)) { $parentData = $form->getParent()->getData(); From 57e9bccc9020936db6b022d6813155ca6f5d5406 Mon Sep 17 00:00:00 2001 From: Kevin Archer Date: Thu, 8 Nov 2012 00:29:25 -0500 Subject: [PATCH 2/5] Update cookbook/form/create_form_type_extension.rst Change services class path to match namespace declared in Extension class --- cookbook/form/create_form_type_extension.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cookbook/form/create_form_type_extension.rst b/cookbook/form/create_form_type_extension.rst index 5c7e974c24c..390c78dc1e4 100644 --- a/cookbook/form/create_form_type_extension.rst +++ b/cookbook/form/create_form_type_extension.rst @@ -104,20 +104,20 @@ tag: services: acme_demo_bundle.image_type_extension: - class: Acme\DemoBundle\Form\Type\ImageTypeExtension + class: Acme\DemoBundle\Form\Extension\ImageTypeExtension tags: - { name: form.type_extension, alias: file } .. code-block:: xml - + .. code-block:: php $container - ->register('acme_demo_bundle.image_type_extension', 'Acme\DemoBundle\Form\Type\ImageTypeExtension') + ->register('acme_demo_bundle.image_type_extension', 'Acme\DemoBundle\Form\Extension\ImageTypeExtension') ->addTag('form.type_extension', array('alias' => 'file')); The ``alias`` key of the tag is the type of field that this extension should From e2d68f5d844ff943a79697c1629488f02c4af0ea Mon Sep 17 00:00:00 2001 From: Kevin Archer Date: Thu, 8 Nov 2012 00:59:32 -0500 Subject: [PATCH 3/5] Update cookbook/form/create_form_type_extension.rst Removing unused use statement --- cookbook/form/create_form_type_extension.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/cookbook/form/create_form_type_extension.rst b/cookbook/form/create_form_type_extension.rst index 390c78dc1e4..a0c36c6cf6d 100644 --- a/cookbook/form/create_form_type_extension.rst +++ b/cookbook/form/create_form_type_extension.rst @@ -186,7 +186,6 @@ it in the view:: namespace Acme\DemoBundle\Form\Extension; use Symfony\Component\Form\AbstractTypeExtension; - use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\Util\PropertyPath; From f7d0cd4bc21c04bb7df0b6306c50b5cdf1ad3f2e Mon Sep 17 00:00:00 2001 From: Kevin Archer Date: Thu, 8 Nov 2012 01:04:55 -0500 Subject: [PATCH 4/5] Update cookbook/form/create_form_type_extension.rst Adding a check to ensure a PropertyPath object is never created with null data causing an exception. --- cookbook/form/create_form_type_extension.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cookbook/form/create_form_type_extension.rst b/cookbook/form/create_form_type_extension.rst index a0c36c6cf6d..3e25f512295 100644 --- a/cookbook/form/create_form_type_extension.rst +++ b/cookbook/form/create_form_type_extension.rst @@ -225,8 +225,13 @@ it in the view:: if (array_key_exists('image_path', $options)) { $parentData = $form->getParent()->getData(); - $propertyPath = new PropertyPath($options['image_path']); - $imageUrl = $propertyPath->getValue($parentData); + if (null !== $parentData) { + $propertyPath = new PropertyPath($options['image_path']); + $imageUrl = $propertyPath->getValue($parentData); + } else { + $imageUrl = null; + } + // set an "image_url" variable that will be available when rendering this field $view->set('image_url', $imageUrl); } From 8c944e443caed24b886588f74cda79c2263534b7 Mon Sep 17 00:00:00 2001 From: Kevin Archer Date: Thu, 8 Nov 2012 01:08:13 -0500 Subject: [PATCH 5/5] Update cookbook/form/create_form_type_extension.rst Removing deprecated use of FormView set method --- cookbook/form/create_form_type_extension.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/form/create_form_type_extension.rst b/cookbook/form/create_form_type_extension.rst index 3e25f512295..5de981105b9 100644 --- a/cookbook/form/create_form_type_extension.rst +++ b/cookbook/form/create_form_type_extension.rst @@ -233,7 +233,7 @@ it in the view:: } // set an "image_url" variable that will be available when rendering this field - $view->set('image_url', $imageUrl); + $view->vars['image_url'] = $imageUrl; } }