Answer the question
In order to leave comments, you need to log in
Sonata Page pass parameters to block via container?
Hello.
I want to pass parameters from the container to the block, but it does not accept custom parameters. Page service:
class LoginPageService extends DefaultPageService
{
public function execute(PageInterface $page, Request $request, array $parameters = [], Response $response = null)
{
$parameters['test'] = 'test';
return parent::execute($page, $request, $parameters, $response);
}
}
{{ sonata_page_render_container('content', 'global', {'test': test}) }}
An exception has been thrown during the rendering of a template ("The option "test" does not exist. Defined options are: "attr", "class", "code", "extra_cache_keys", "layout", "manager", "page_id", "template", "ttl", "use_cache".").
Answer the question
In order to leave comments, you need to log in
Options are forwarded to BlockService, so it is necessary to configure custom options in the corresponding block by implementing the configureOptions method.
https://github.com/sonata-project/SonataPageBundle...
Above you can see that the container (the first argument of the twig function) is the block. Redefine the block service or modify an already redefined one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question