-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Add label_raw attribute to form theme #31358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Form] Add label_raw attribute to form theme #31358
Conversation
7cae00f
to
1170b70
Compare
Could you please prepare a doc PR ? |
Should we add the |
I am not convinced that this is a common enough use case to have it as part of the core form themes. |
But maybe I am wrong with that assumption. See #31375 for another approach which tackles the same use case. |
In my opinion, HTML inside a label is quite common, e.g. bolded text for part of a label, link in a checkbox used for accepting some terms or regulations, icons on a button. I would recommend adding this option, same as was done with |
Yeah think this would make some things easier. The usecase I have mostly in all forms is the data privacy protection checkbox with a tag link in it. As there is something like I will close this PR in favor of @przemyslaw-bogusz #31375 PR |
@alexander-schranz Thank you very much for the support! |
This PR was squashed before being merged into the 5.1-dev branch. Discussion ---------- [Form] Add label_html attribute | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT | Doc PR | symfony/symfony-docs#13316 I propose to add a new attribute to `BaseType` class so it is easy to include html tags in labels for, both, buttons and other elements that inherit from `FormType` class. This gives you an ability to add, e.g. a glyphicon to a button, or a link to a checkbox, simply inside the `FormBuilder`, which means you can just do ```twig {{ form(form) }} ``` inside a template. **Sidenotes** 1. I have started working on this two days ago and it the meantime @alexander-schranz made a similar proposition in #31358. If necessary, I can close my PR and @alexander-schranz can include my suggestions inside his PR. 1. I have just read in #29861 that @mpiot wanted to include this idea in his PR. With respect to @xabbuh's comments from that PR, I hope that my PR will be at least a good place to discuss, if the proposed feature is a good solution. Commits ------- 239fe04 [Form] Add label_html attribute
There are some usecases where you want to render a label as raw (e.g. checkbox with a link in it). This change should make it easier todo this without copying the whole form_label block logic.
Example:
Should we add this also to the FormExtension as attribute? Or is it a theming only thing like #30320.