-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form][TwigBridge] Add help_html #29861
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
Conversation
Thanks @mpiot, could you please rebase to fix the conflicts? They must be related to the move to short arrays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I just rebased for you)
Thank you @mpiot. |
This PR was merged into the 4.3-dev branch. Discussion ---------- [Form][TwigBridge] Add help_html | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | no | License | MIT | Doc PR | symfony/symfony-docs#... Sometimes, when we use the form `help` option, we want to display it as HTML (add bold, italic, a span with a specific class, ...). For security reasons, we escape the `help` content. In this PR, I've added an `help_html` option, seted to false per default. When it set on true, the `help` content is no longer escaped. Commits ------- 33f5f85 [Form][TwigBridge] Add help_html option
Thanks a lot :-) I was thinking about doing this tonight, it's faster like this :D |
This PR was merged into the master branch. Discussion ---------- [FormType] Add help_html documentation Add documentation about the new feature symfony/symfony#29861 Commits ------- cc6a5f3 Add help_html
I wonder if we should also add a boolean option |
@scuben I can do that, (I've hesitate to do that when I've done this PR), but is it really usefull ? |
@mpiot I just had a use case to add a TOS link to the label of a checkbox and would have loved this feature 👍 |
@scuben Okay, I see, then it should be implement in CheckboxType, RadioType, and ChoiceType only ? |
I would implement it in any type which would reduce complexity as you know you can relay on that it's available in any label. |
It's comprehensive, then it's easier to implement too. I start it, when I've some times :-) |
I think it would be better to discuss this in a new issue before investing time in something that might not be merged. Personally, I don't see this as a common use case and would rather suggest to use a custom form theme for cases when you really need this instead. |
Okay, then @scuben, can you create an Issue ? You can refer it and ping me, if there are a real interest from users, I'll do it. For the moment, I've must do that one times, and I've used a custom form theme thath extends which theme I use, with a custom type. |
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
Sometimes, when we use the form
help
option, we want to display it as HTML (add bold, italic, a span with a specific class, ...). For security reasons, we escape thehelp
content.In this PR, I've added an
help_html
option, seted to false per default. When it set on true, thehelp
content is no longer escaped.