Permalink
Browse files

Possibility to overwrite formextra twig blocks, realpath for base_pat…

…h to replace correctly in image type, use of asset in image type
  • Loading branch information...
1 parent 72c06df commit 09243c2a91317342b2f737809449bf6048e1b0d1 @cdfre cdfre committed Feb 28, 2012
View
4 DependencyInjection/Compiler/TwigFormPass.php
@@ -19,8 +19,8 @@ public function process(ContainerBuilder $container)
}
$container->setParameter('twig.form.resources', array_merge(
- $container->getParameter('twig.form.resources'),
- array('SimpleThingsFormExtraBundle:Form:div_layout.html.twig')
+ array('SimpleThingsFormExtraBundle:Form:div_layout.html.twig'),
+ $container->getParameter('twig.form.resources')
));
}
}
View
2 Form/Type/ImageType.php
@@ -56,7 +56,7 @@ public function buildView(FormView $view, FormInterface $form)
if ($data && (strpos($data->getPath(), $form->getAttribute('base_path')) === 0)) {
/* @var $data SplFileInfo */
- $uri = str_replace($form->getAttribute('base_path'), $form->getAttribute('base_uri'), $data->getRealPath());
+ $uri = str_replace(realpath($form->getAttribute('base_path')), $form->getAttribute('base_uri'), $data->getRealPath());
if ('/' !== DIRECTORY_SEPARATOR) {
$uri = str_replace(DIRECTORY_SEPARATOR, '/', $uri);
}
View
2 Resources/views/Form/div_layout.html.twig
@@ -17,7 +17,7 @@
{% spaceless %}
<div class="form_image">
{% if image_uri is defined %}
- <img src="{{ image_uri }}" alt="{{ image_alt }}"{% if image_height > 0 %} height="{{ image_height }}"{% endif %}{% if image_width > 0 %} width="{{ image_width }}"{% endif %}/>
+ <img src="{{ asset(image_uri) }}" alt="{{ image_alt }}"{% if image_height > 0 %} height="{{ image_height }}"{% endif %}{% if image_width > 0 %} width="{{ image_width }}"{% endif %}/>
{% else %}
{% trans %}No image uploaded.{% endtrans %}
{% endif %}

0 comments on commit 09243c2

Please sign in to comment.