Replies: 2 comments
-
It comes from the {% extends 'form_div_layout.html.twig' %}
{% block form_widget %}
{% if label_html is same as(false) %}
{% set attr = attr|merge({label: block('form_label_content') }) %}
{% endif %}
{{ parent() }}
{% endblock form_widget %}
{% block form_label %}
{% if label_html is same as(true) %}
{% set label_attr = label_attr|merge({slot: 'label'}) %}
{{ parent() }}
{% endif %}
{% endblock form_label %} Wouldn’t it be simpler to always use the |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks a lot.
I will continue watching the Symfony Casts lessons on form theming to go deeper into the subject.
All the best,
François
…--
Sent from Canary (https://canarymail.io)
On lundi, juil. 14, 2025 at 9:58 PM, Mathieu ***@***.*** ***@***.***)> wrote:
>
> I do not know how to avoid the display of an HTML label element
>
It comes from the form_label block so you have to override it. Note that labels can contain HTML so you’d need to check the label_html option, e.g.
{% extends 'form_div_layout.html.twig' %} {% block form_widget %} {% if label_html is same as(false) %} {% set attr = attr|merge({label: block('form_label_content') }) %} {% endif %} {{ parent() }} {% endblock form_widget %} {% block form_label %} {% if label_html is same as(true) %} {% set label_attr = label_attr|merge({slot: 'label'}) %} {{ parent() }} {% endif %} {% endblock form_label %}
—
Reply to this email directly, view it on GitHub (#61102 (comment)), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AA5AL2YXYR5KO2JHXRMVQCL3IQDUTAVCNFSM6AAAAACBJIP7XKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGNZVGY2TMNY).
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am starting a new form theme on top of
form_div_layout.html.twig
that uses web Awesome/shoelace form components.The issue with Web Awseome is that, in most input, the input label is not set as an HTML element, but rather as a slot of the custom input element. Here is a sample code for an input with a label:
<wa-input label="What is your name?"></wa-input>
I think I can read the value of the label for the input field, but I do not know how to avoid the display of an HTML
label
element, as usually produced in the theme rendering.How can I avoid the production of the
label
element without, naturally, tweaking the user's form class?TIA
François
Beta Was this translation helpful? Give feedback.
All reactions