0

Is it possible to add twig directives to field options in a Sonata Admin field option?

$fileFieldOptions = array('required' => false, 'data_class' => null);
if ($image && ($webPath = $image->getS3PathToImage())) {
    // get the container so the full path to the image can be set
    $container = $this->getConfigurationPool()->getContainer();
    $fullPath = 'http://'.$webPath;

    // add a 'help' option containing the preview's img tag
    //$fileFieldOptions['help'] = '<img src="'.$fullPath.'" class="admin-preview" />';
    $fileFieldOptions['help'] = "<img src='{{ '/relative/path/to/image.jpg' | imagine_filter('gi_thumb') }}' />";

I tried safe => true as suggested here but it does not seem to work with form fields.

Community
  • 1
  • 1
codecowboy
  • 9,835
  • 18
  • 79
  • 134
  • It's better to create your own [field type](http://sonata-project.org/bundles/doctrine-orm-admin/master/doc/reference/list_field_definition.html) – tttony Apr 27 '14 at 22:49
  • @tttony thanks. What is 'providername' used in the template at that url? – codecowboy Apr 28 '14 at 08:01
  • it's just an example, the `object` is the entity, you can access to the methods of the entities – tttony Apr 28 '14 at 16:18

0 Answers0