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

[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

Conversation

@alexander-schranz
Copy link
Contributor

@alexander-schranzalexander-schranz commentedMay 2, 2019
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#...
LicenseMIT
Doc PRsymfony/symfony-docs#11513

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.

@alexander-schranzalexander-schranz changed the titleAdd label_raw attribute to form theme[Form] Add label_raw attribute to form themeMay 2, 2019
@Simperfit
Copy link
Contributor

Could you please prepare a doc PR ?

@alexander-schranz
Copy link
ContributorAuthor

alexander-schranz commentedMay 2, 2019
edited
Loading

Should we add thelabel_raw attribute also to theBaseType? So it can also be controlled from PHP? As I think it always depends on the used translation key which is also be configured in PHP.

@xabbuh
Copy link
Member

I am not convinced that this is a common enough use case to have it as part of the core form themes.

@xabbuh
Copy link
Member

But maybe I am wrong with that assumption. See#31375 for another approach which tackles the same use case.

@przemyslaw-bogusz
Copy link
Contributor

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 withhelp. There should be a way to add HTML, without having to do much tweaking inside Twig.

@alexander-schranz
Copy link
ContributorAuthor

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 likehelp_html I think its totally make sense to have alsolabel_html in it.

I will close this PR in favor of@przemyslaw-bogusz#31375 PR

@alexander-schranzalexander-schranz deleted the feature/easier-label-raw branchMay 9, 2019 16:57
@przemyslaw-bogusz
Copy link
Contributor

@alexander-schranz Thank you very much for the support!

@nicolas-grekasnicolas-grekas modified the milestones:next,4.4Oct 27, 2019
nicolas-grekas added a commit that referenced this pull requestMar 12, 2020
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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

6 participants

@alexander-schranz@Simperfit@xabbuh@przemyslaw-bogusz@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp