Answer the question
In order to leave comments, you need to log in
How to overwrite a variable from its own field type?
I create my own field type inherited from CheckBoxType
getParent = CheckboxType::class
getBlockPrefix = mycheckbox
In the options I start a new variable my_label
In the field template:
{% block mycheckbox_widget %}
{% set label = my_label %}
{{ block('checkbox_widget') }}
{% endblock %}
Answer the question
In order to leave comments, you need to log in
Options are not available in view. To do this, add the following code:
CheckBoxType:
/**
* @inheritDoc
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['my_label'] = $options['my_label'];
// Либо сразу
// $view->vars['label'] = $options['my_label'];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question