Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 498 Bytes

field-template-vars.md

File metadata and controls

18 lines (15 loc) · 498 Bytes

Sonata field template vars

Description

Sometimes you will need additional variables in your field templates. This is how you can add those.

Code

Inside the Admin class, in the configureShowFields or configureFormFields methods:

$builder->add('fieldName', 'fieldType', [
    'template' => 'your-template-file.html.twig',
    'your_template_var' => $yourTemplateVar
]);

In the your-template-file.html.twig template:

{{ field_description.options.your_template_var }}