Symfony provides two bootstrap form themes (amongst others) which define "checkbox_row" blocks.
I attempted to use those in my twig templates, only resulting in the following error:
The function "checkbox_row" does not exist in CompanyBundle:OrderingRule:new.html.twig at line 17
In my config.yml file I have set:
form:
resources: ['bootstrap_3_layout.html.twig']
Here's my twig
{{ form_start(form, {'attr': {'novalidate': 'novalidate'}, 'action': path('ordering_rule_create'), 'method': 'POST'}) }}
<div class="row">
<div class="col-lg-3">
<p class="small">Step 1 of 4:</p>
<p>Order Types</p>
</div>
<div class="col-lg-9">
{{ checkbox_row(form.isMealsIncluded) }}
{{ form_row(form.isCateringIncluded, {'label': 'Catering'}) }}
{{ form_row(form.billingType, {'label': null}) }}
</div>
</div>
<div class="row">
<div class="col-lg-3">
<p class="small">Step 2 of 4:</p>
<p>Applicable To</p>
</div>
<div class="col-lg-9">
{{ form_row(form.applicableType) }}
{{ form_row(form.companyLocations) }}
{{ form_row(form.companyDepartments) }}
</div>
</div>
<div class="row">
<div class="col-lg-3">
<p class="small">Step 3 of 4:</p>
<p>Select days and time<br>when users can order</p>
</div>
<div class="col-lg-9">
{{ form_row(form.applicableWeekdays) }}
{{ form_row(form.applicableTimeFrom) }}
{{ form_row(form.applicableTimeTo) }}
</div>
</div>
<div class="row">
<div class="col-lg-3">
<p class="small">Step 4 of 4:</p>
<p>Budget</p>
</div>
<div class="col-lg-9">
{{ form_row(form.budget) }}
</div>
</div>
{{ form_end(form) }}
You are confusing form fragments with means of rendering a form
This is how the checkbox row is render as a fragment in bootstrap_3_layout.html.twig
But you can't use the function like this.
You can override it by defining the block in your template:
EDIT
How to render a form field:
or
this is how you can render a field, there are no other way. You can still render the form globally by
{{form(form)}}
But the existence of the fragment
checkbox_row
is intended to allow you a good way of rendering customization