-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Add ability to clear form errors #27571
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
Update to latest symfony master
Thank you for re-creating and re-submitting my old commit! 👍 |
* | ||
* @return FormInterface The form instance | ||
*/ | ||
public function clearErrors($deep = false); |
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 don't think this will be possible. You'll have to make this work for 4.x as well and as is, it's a BC break. Probably requires a new interface, which can be merged in this interface in 5.0.
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.
Do you mean I should create something like FormClearErrorsInterface
and make Form
implement that?
If we want to merge it into FormInterface
in 5.0, does that mean the FormClearErrorsInterface
should be marked as deprecated right away, so that people will be aware that it goes away in version 5.0?
I have not done something like this before, so that is why I would apreciate some guideance in how to do it. Thanks.
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.
Also @dosten wrote in #14233 (comment) that the BC break would not be a problem.
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.
Also @dosten wrote in #14233 (comment) that the BC break would not be a problem.
The BC promise states that adding a new method is not acceptable http://symfony.com/doc/current/contributing/code/bc.html#changing-interfaces
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.
@TerjeBr The comment you linked dates from 2015, since then the concept of @api
interface was removed and we now consider every class as part of the public API (#15977, symfony/symfony-docs#5735). This means we can't add methods to any interface.
Please correct me if I am misstaken, but is the Is this interfece not more kind of "internal" to the Symfony framework? |
Only if an interface is marked as |
I am trying to find a way forward here. Is it reasonable to want to mark |
Or if I do as @iltar suggested, add a new interface, should that interface be created with the tag |
Let's ping our Symfony Form expert @vudaltsov to see if he can spot any issue here (besides the interface issue mentioned by Iltar). |
This PR can be closed in favor of #27580. |
@@ -10,6 +10,7 @@ CHANGELOG | |||
* deprecated the `ChoiceLoaderInterface` implementation in `CountryType`, `LanguageType`, `LocaleType` and `CurrencyType` | |||
* added `input=datetime_immutable` to DateType, TimeType, DateTimeType | |||
* added `rounding_mode` option to MoneyType | |||
* added `FormInterface::clearErrors()` method |
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.
we cannot do this in a minor release as it is a BC break
* | ||
* @return FormInterface The form instance | ||
*/ | ||
public function clearErrors($deep = false); |
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.
This is a BC break that needs to be reverted.
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function clearErrors($deep = false) |
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.
public function clearErrors(bool $deep = false): void
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
This PR adds the ability to manually clear form errors, thus improving the DX issue reported in #14060.
This is a copy of PR #14233