I try to create a custom form theme for my project where I want to render all checkbox fields INSIDE the label like:
<label><input type="checkbox" /><label>
I've found out that I have to change the choice_widget_expanded block for this:
{% block choice_widget_expanded %}
{% spaceless %}
<div {{ block('widget_container_attributes') }}>
{% for child in form %}
{{ form_widget(child) }}
{{ form_label(child) }}
{% endfor %}
</div>
{% endspaceless %}
{% endblock choice_widget_expanded %}
The problem is, when I copy the content of the form_label block into the container instead of calling form_label(child), I don't really see how the block accesses the variable passed(which was child when I called the function), and how to call the form_widget function in the form_label block:
{% block form_label %}
<label>{{ form_widget(?? what to put here??) }}</label>
{% endblock form_label %}
Also, if I create a block with a different name, like "form_label_extra" and try to call it, it throws an error, because it's not a registered twig function.
Does anyone know how this variables are passed between the form blocks, and how to achieve my goal?