Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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 ourterms of service andprivacy 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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
7cae00f to1170b70CompareSimperfit commentedMay 2, 2019
Could you please prepare a doc PR ? |
alexander-schranz commentedMay 2, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Should we add the |
xabbuh commentedMay 4, 2019
I am not convinced that this is a common enough use case to have it as part of the core form themes. |
xabbuh commentedMay 4, 2019
But maybe I am wrong with that assumption. See#31375 for another approach which tackles the same use case. |
przemyslaw-bogusz commentedMay 9, 2019
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 |
alexander-schranz commentedMay 9, 2019
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 |
przemyslaw-bogusz commentedMay 9, 2019
@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#13316I 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
Uh oh!
There was an error while loading.Please reload this page.
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:
{%block_my_label %} {%-setlabel_raw=true -%} {{-block('form_label') -}}{%endblock %}Should we add this also to the FormExtension as attribute? Or is it a theming only thing like#30320.