Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] Ability to clear form errors #9916

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 3 commits into from
Jun 25, 2018
Merged

[Form] Ability to clear form errors #9916

merged 3 commits into from
Jun 25, 2018

Conversation

colinodell
Copy link
Contributor

Documenting the new feature proposed in symfony/symfony#27580

Clearing Form Errors
~~~~~~~~~~~~~~~~~~~~

Any errors can be manually cleared using the :method:`Symfony\\Component\\Form\\ClearableErrorInterface::clearErrors` method. This is useful when you'd like to validate the form without showing validation errors to the user (i.e. during a partial AJAX submission or :doc:`dynamic form modification </form/dynamic_form_modification>`).
Copy link
Member

Choose a reason for hiding this comment

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

ClearableErrorsInterface? s

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I renamed the interface but forgot to update the docs. Fixed and amended!

Clearing Form Errors
~~~~~~~~~~~~~~~~~~~~

Any errors can be manually cleared using the :method:`Symfony\\Component\\Form\\ClearableErrorsInterface::clearErrors` method. This is useful when you'd like to validate the form without showing validation errors to the user (i.e. during a partial AJAX submission or :doc:`dynamic form modification </form/dynamic_form_modification>`).
Copy link
Contributor

Choose a reason for hiding this comment

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

We should precise that clearing the errors makes the form valid. So clearErrors() should be called after testing if the form is valid or at least not rely on its state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a new sentence to clarify that. Thanks!

Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

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

Thanks!

symfony-splitter pushed a commit to symfony/form that referenced this pull request Jun 25, 2018
This PR was squashed before being merged into the 4.2-dev branch (closes #27580).

Discussion
----------

[Form] Add ability to clear form errors

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14060
| License       | MIT
| Doc PR        | symfony/symfony-docs#9916

This PR adds the ability to manually clear form errors, thus improving the DX issue reported in #14060.

Unlike my original approach in #14233 and #27571 which break BC, this adds a new `ClearableErrorInterface` which `Form` implements.  (`Button` does not implement it because buttons can't have errors.)

Commits
-------

9eb755c07f [Form] Add ability to clear form errors
fabpot added a commit to symfony/symfony that referenced this pull request Jun 25, 2018
This PR was squashed before being merged into the 4.2-dev branch (closes #27580).

Discussion
----------

[Form] Add ability to clear form errors

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14060
| License       | MIT
| Doc PR        | symfony/symfony-docs#9916

This PR adds the ability to manually clear form errors, thus improving the DX issue reported in #14060.

Unlike my original approach in #14233 and #27571 which break BC, this adds a new `ClearableErrorInterface` which `Form` implements.  (`Button` does not implement it because buttons can't have errors.)

Commits
-------

9eb755c [Form] Add ability to clear form errors
@javiereguiluz javiereguiluz removed the Waiting Code Merge Docs for features pending to be merged label Jun 25, 2018
@javiereguiluz
Copy link
Member

@colinodell thanks for improving Forms DX with this new feature and thanks for providing the docs too. Everything is perfectly explained!

@javiereguiluz javiereguiluz merged commit f07f536 into symfony:master Jun 25, 2018
javiereguiluz added a commit that referenced this pull request Jun 25, 2018
…uiluz)

This PR was merged into the master branch.

Discussion
----------

[Form] Ability to clear form errors

Documenting the new feature proposed in symfony/symfony#27580

Commits
-------

f07f536 Wrap long lines and add the versionadded directive
7a4465d Clarify that clearing errors makes the form valid
d4143f1 [Form] Ability to clear form errors
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