Maybe I'm missing something, and I hope this is done very easily.
I have a form, and in the end I want to get the following result:
Fields that:
- are required / required
- there is a mistake now
- have help
should get an extra a-Tag after the label and an extra div filled with help and / or an error, if applicable.
What I need is that the required fields get a-Tag using this:
{% use 'form_div_layout.html.twig' with field_label as base_field_label %}
{% block field_label %}
{{ block('base_field_label') }}
{% if required %}
<a href=""><span> </span></a>
{% endif %}
{% endblock %}
So, I already tried different versions of this:
{% use 'form_div_layout.html.twig' with field_label as base_field_label %}
{% block field_label %}
{{ block('base_field_label') }}
{% if required or help is defined %}
<a href=""><span> </span></a>
{% endif %}
{% endblock %}
{% block field_row %}
{% spaceless %}
<div class="row">
{% if required or help is defined %}
<div>
{{ form_errors(form) }}
{{ help }}
</div>
{% endif %}
{{ form_label(form) }}
{{ form_widget(form, { 'attr': {'class': 'grid_4'} }) }}
</div>
{% endspaceless %}
{% endblock field_row %}
And I can't get this to work.
So my questions are:
Where can I get help text that may also contain HTML? I tried this in form builderwithout success - but at least with the exception of:
$builder ->add('subject', 'text', array(
'label' => 'Subject',
'help' => 'Can be formatted content with <strong>HTML-Elements</strong>',
));
, ( ), , ? {{ form_errors(form) }} , , field_row.