I am having issues overriding a label in my form in my Symfony 4.4 application:
{{ form_row(form.legal, {
'label' : 'personal.form.fields.legal'|trans
}) }}
personal.form.fields.legal
looks like this:
I agree that I am 18 and above, I have read and accept the <a href="/terms-cond">T&Cs</a>
My form definition:
->add('legal', CheckboxType::class,
'required' => true,
'mapped' => false,
])
My attempt at overriding this label is this:
{% block _crmbundle_personal_legal_label %}
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %} style="color: red;">
{{ form_widget(form) }}
{{ label|unescape|raw }}
</label>
{%- endblock %}
I have a Twig extension that does this:
public function getFilters(): array
{
return [
new TwigFilter('unescape', function ($value) {
return html_entity_decode($value);
}),
];
}
I am finding this duplicates the label and I can't find a way to correct this. I have one checkbox, but two labels (both showing in red)