I want to get all the variables available in the Symfony form theme file form_div_layout.html.twig, I read the Symfony official documention and searched on the web, but couldn't find any useful information on this, can someone help me?
相关问题
- Symfony2 Set Controller in the kernelControllerEve
- Webpack Encore: cannot import local dependencies
- Render custom attribute KNP Menu
- Problems with cap deploy a symfony2 project, can
- Allow CORS on symfony 4
相关文章
- Symfony : Doctrine data fixture : how to handle la
- Symfony is linked to the wrong PHP version
- Symfony2: check whether session exists or not
- Is there a way to modify the entity mapping config
- symfony2 form choice and mongodb
- What is the Twig equivalent of isset() and !empty(
- Symfony 3.1 and OneUpUploaderBundle + Blueimp = Up
- Symfony does not remove entity from collection
You can pull all of the ones out of the original file, and only overload the ones that you need:
Well, you can get all the available variables in each block by iterating the context:
And if you want to use yours, then you'll have to overwrite the classes that actually are rendering those widgets, just take a look at AbtractType::buildView...
As @Gregoire suggested, you can use
{{ dump(_context) }}
from version 1.5 (http://twig.sensiolabs.org/doc/functions/dump.html), but be aware that it will print a big amount of info.See my answer here: https://stackoverflow.com/a/41020474/5758328
You simply need to use
and all variables available in the template will be dumped to the profiler
I hit the same problem recently, being the lack of documentation on the available variables (attributes) when working in themes. In the end I found my solution by searching through the vendor folder (took a while) for the variables I did know, to see what else is available.
The best place for me was to look in here: Symfony\Component\Form\Extension\Core\Type
The base type, being FieldType provides these variables via buildView
prototype is an attribute that only exists in the collection type, as is allow_add and allow_delete, see CollectionType in the same folder.
After the base FieldType, this appears to be the complete list.