Skip to content

Modifying bootstrap 4 label for checkbox removes the actual input element #28823

@ThePeterMick

Description

@ThePeterMick

Symfony version(s) affected: 4.1.4

Description
If you try to override only a label of a checkbox, the input element disappears.

The custom label is shown once if using ‘form_widget’ and twice if using ‘form_row’, the actual checkbox/input never appears, just the label.

How to reproduce
Use in a twig view:

{% form_theme form _self %}

{% block _user_registration_form_termsAccepted_label %}
    <label class="form-check-label required" for="user_registration_form_termsAccepted">{{ 'label.terms_accepted'|trans({ '%terms_and_conditions_link%': path('terms') })|raw }}</label>
{% endblock %}

Render via {{ form_widget(form.termsAccepted) }} - shows the label once, with an indent (form-check div wrap)
Render via {{ form_row(form.termsAccepted) }} - shows the label twice, one without an indent and second with an indent same as with form_widget

Possible Solution

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions