Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Help on developing a new twig form theme using Web Awesome (formerly shoelace) elements#61102

Unanswered
snorky22 asked this question inQ&A
Discussion options

I am starting a new form theme on top ofform_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 HTMLlabel element, as usually produced in the theme rendering.

How can I avoid the production of thelabel element without, naturally, tweaking the user's form class?

TIA
François

You must be logged in to vote

Replies: 2 comments

Comment options

I do not know how to avoid the display of an HTMLlabel element

It comes from theform_label block so you have to override it. Note that labels can contain HTML so you’d need to check thelabel_html option, e.g.

{%extends'form_div_layout.html.twig' %}{%blockform_widget %}    {%iflabel_htmlissame as(false) %}        {%setattr=attr|merge({label:block('form_label_content') }) %}    {%endif %}    {{parent() }}{%endblockform_widget %}{%blockform_label %}    {%iflabel_htmlissame as(true) %}        {%setlabel_attr=label_attr|merge({slot:'label'}) %}        {{parent() }}    {%endif %}{%endblockform_label %}

Wouldn’t it be simpler to always use thelabel slot?

You must be logged in to vote
0 replies
Comment options

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: ***@***.***>
You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@snorky22@MatTheCat

[8]ページ先頭

©2009-2025 Movatter.jp