@@ -106,20 +106,20 @@ tag:
106
106
107
107
services :
108
108
acme_demo_bundle.image_type_extension :
109
- class : Acme\DemoBundle\Form\Type \ImageTypeExtension
109
+ class : Acme\DemoBundle\Form\Extension \ImageTypeExtension
110
110
tags :
111
111
- { name: form.type_extension, alias: file }
112
112
113
113
.. code-block :: xml
114
114
115
- <service id =" acme_demo_bundle.image_type_extension" class =" Acme\DemoBundle\Form\Type \ImageTypeExtension" >
115
+ <service id =" acme_demo_bundle.image_type_extension" class =" Acme\DemoBundle\Form\Extension \ImageTypeExtension" >
116
116
<tag name =" form.type_extension" alias =" file" />
117
117
</service >
118
118
119
119
.. code-block :: php
120
120
121
121
$container
122
- ->register('acme_demo_bundle.image_type_extension', 'Acme\DemoBundle\Form\Type \ImageTypeExtension')
122
+ ->register('acme_demo_bundle.image_type_extension', 'Acme\DemoBundle\Form\Extension \ImageTypeExtension')
123
123
->addTag('form.type_extension', array('alias' => 'file'));
124
124
125
125
The ``alias `` key of the tag is the type of field that this extension should
@@ -239,10 +239,14 @@ it in the view::
239
239
if ($form->hasAttribute('image_path')) {
240
240
$parentData = $form->getParent()->getData();
241
241
242
- $propertyPath = new PropertyPath($form->getAttribute('image_path'));
243
- $imageUrl = $propertyPath->getValue($parentData);
242
+ if (null != $parentData) {
243
+ $propertyPath = new PropertyPath($form->getAttribute('image_path'));
244
+ $imageUrl = $propertyPath->getValue($parentData);
245
+ } else {
246
+ $imageUrl = null;
247
+ }
244
248
// set an "image_url" variable that will be available when rendering this field
245
- $view->set( 'image_url', $imageUrl) ;
249
+ $view->vars[ 'image_url'] = $imageUrl;
246
250
}
247
251
}
248
252
0 commit comments