The problem
The TwigField is basically just a normal field with a default template. The problem is if you want to change the options of this field it will either have to specify the template again or you will lose it.
Example
<?php
$field = TwigField::create('some_field', '@Sylius/some_template.html.twig')
->setOptions(['vars' => ['labels' => 'path/to/label'])
;
Will result in the options being:
[
'vars' => ['labels' => 'path/to/label']
]
and not:
[
'template' => '@Sylius/some_template.html.twig',
'vars' => ['labels' => 'path/to/label']
]
Possible solution
The quick and easy answer would be to have the TwigField extend the Field and change the behavior of the setOptions function to merge with the template. This would be a big change though.
The problem
The
TwigFieldis basically just a normal field with a default template. The problem is if you want to change the options of this field it will either have to specify the template again or you will lose it.Example
Will result in the options being:
and not:
Possible solution
The quick and easy answer would be to have the
TwigFieldextend theFieldand change the behavior of thesetOptionsfunction to merge with the template. This would be a big change though.