Background
I want to display entity-independent information in the EDIT-page. According to the official documentation it can be solved with configureResponseParameters
-function.
Problem
So I implemented that function into my CRUD-controller.
- on INDEX twig template: I can use/find the variable
- on EDIT twig template: I cannot use/find the variable
Any idea why?
How can I achieve to pass data to my EDIT-twig template? Many Thanks!
My Files
PersonCrudController.php
class PersonCrudController extends AbstractCrudController {
public function configureCrud(Crud $crud): Crud {
$crud->setFormThemes([
'mystuff/person_edit_form.html.twig', '@EasyAdmin/crud/form_theme.html.twig'
]);
return $crud;
}
public function configureFields(string $pageName): iterable {
// ...
yield TextField::new('specialDisplay')->setFormTypeOption('mapped', false);
// ...
}
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{
$responseParameters->set('testtesttest', '123xyz');
return $responseParameters;
}
// ...
}
mystuff/person_edit_form.html.twig
{% block _Person_specialDisplay_row %}
{{ testtesttest }} {# throws: Variable "testtesttest" does not exist. #}
{{ dump() }} {# cannot find "testtesttest" anywhere in dump #}
{# ... here comes the rest that is working perfectly ... #}
{% endblock %}