Skip to content

Readd 'form_label_errors' block to disable errors on form labels #26408

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

Merged
merged 1 commit into from
Mar 18, 2018
Merged

Readd 'form_label_errors' block to disable errors on form labels #26408

merged 1 commit into from
Mar 18, 2018

Conversation

birkof
Copy link
Contributor

@birkof birkof commented Mar 5, 2018

Q A
Branch? 3.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT

Re-added form_label_errors block on bootstrap 4 form themes.
You can disable errors shown on form labels by simply extend bootstrap4 layout and empty form_label_errors block. See below:

{% use "bootstrap_4_layout.html.twig" %}

{# Disable errors shown on form labels #}
{% block form_label_errors %}{% endblock form_label_errors %}

Block previously removed here by @nicolas-grekas.
cc @Nyholm

@Nyholm
Copy link
Member

Nyholm commented Mar 5, 2018

Thank you for this PR.
I had that block in my initial PR (#24435). I think it is a good way to opt-out form having the errors in the labels. However, I would strongly recommend against opting-out.

Btw, This is a feature and not a bug.

Protip: There is no need of closing the PR and open a new one. Just push your changes to the same branch and the PR will be updated.

@birkof
Copy link
Contributor Author

birkof commented Mar 5, 2018

Made the previous pull request in the wrong branch and it collects all the differences & shown as comments... that's why I prefer to close it & open another one.

Thanks!

@Simperfit
Copy link
Contributor

@Nyholm This a is a new feature that we want to introduce in the 3.4 branch, shouldn't it go to master instead ?

@Simperfit
Copy link
Contributor

@birkof Thanks for the first contribution on symfony! ;)

@Nyholm
Copy link
Member

Nyholm commented Mar 6, 2018

Okey, Lets consider it a bugfix then. It is for users that does not use form_row. They will have a (real) hard time customizing the the form.

@ostrolucky
Copy link
Contributor

If somebody needs to do this on per-field basis, this is better approach:

{{ form_label(addUserForm.userByEmail, null, {errors: []}) }}

If you want to disable all errors for form, you can currently do this:

{% form_theme addUserForm _self %}
{% block form_errors %}{% endblock %}

This PR is still a bit different though, because someone might want to disable errors in labels, but not errors via form_errors

@Nyholm
Copy link
Member

Nyholm commented Mar 7, 2018

Exactly. The point is not to disable errors. The point is to disable errors in labels.

@birkof
Copy link
Contributor Author

birkof commented Mar 8, 2018

@ostrolucky didn't know you could disable errors per-field like that. Thanks for the hint!

@veteran29
Copy link

As form_errors call was removed from form_row in this commit, will disabling errors in labels cause error blocks to be not rendered at all?

A simple way to restore old behavior could be useful as errors in labels don't play nice with some Bootstrap 4 themes.

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im 👍

@fabpot
Copy link
Member

fabpot commented Mar 18, 2018

Thank you @birkof.

@fabpot fabpot merged commit 5b4354f into symfony:3.4 Mar 18, 2018
fabpot added a commit that referenced this pull request Mar 18, 2018
…orm labels (birkof)

This PR was merged into the 3.4 branch.

Discussion
----------

Readd 'form_label_errors' block to disable errors on form labels

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| License       | MIT

Re-added **form_label_errors** block on bootstrap 4 form themes.
You can disable errors shown on form labels by simply extend bootstrap4 layout and empty **form_label_errors** block. See below:
```
{% use "bootstrap_4_layout.html.twig" %}

{# Disable errors shown on form labels #}
{% block form_label_errors %}{% endblock form_label_errors %}
```
Block previously removed [here](b375957#diff-62cb2a10f5a37db0e87e3bd81609b17dR186) by @nicolas-grekas.
cc @Nyholm

Commits
-------

5b4354f Readd 'form_label_errors' block to disable errors on form labels
This was referenced Apr 3, 2018
@fabpot fabpot mentioned this pull request May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants