-
Notifications
You must be signed in to change notification settings - Fork 821
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
API Deprecate FormField API #11464
API Deprecate FormField API #11464
Conversation
src/Forms/DateField.php
Outdated
@@ -101,6 +101,7 @@ class DateField extends TextField | |||
* to detect invalid values. | |||
* | |||
* @var mixed | |||
* @deprecated 5.4.0 Will be removed without equivalent functionality to replace it |
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.
* @deprecated 5.4.0 Will be removed without equivalent functionality to replace it | |
* @deprecated 5.4.0 Use $value instead |
Presumably if people want to get the value, they should use the value property. Or the getValue() method.
Please apply this to the other rawValue
deprecation phpdocs as well.
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 think it's correct as is as $this->value is still getting modified in CMS 5 - as mentioned on #11449 (comment) this property has a specific purpose
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.
That comment mentions the past tense, and #11449 (comment) says that getValue()
should return the value "as unmodified as possible". Which I took to mean that the value
property would now be the raw value, and the various methods for getting the value are where any modification of the value would take place.
Is there no way to get just the value that was set to the field now? I thought that was explicitly the purpose of getValue()
?
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.
In the context of Date/Datetime/TimeField, $this->value will get modified after calling setValue($value). $this->rawValue is explicitly not getting modified at any point. There's no equivalent functionality in CMS 5.
My intention, at least, in CMS 6 at least is to not modify $this->value after setting it so that when validation is run it's running on the value that was set by the developer, though in practice Fields could still alter $this->value.
tl;dr Will be removed without equivalent functionality to replace it :-)
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.
Discussed in person - $value
is functionally equivalent to $rawValue
even if the exact value isn't identical
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.
Updated
src/Forms/FormField.php
Outdated
*/ | ||
protected function extendValidationResult(bool $result, Validator $validator): bool | ||
{ | ||
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced by the `updateValidate` extension hook'); |
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.
The method doesn't get replaced with the extension hook - if I'm calling this method in my custom form field I don't now need to implement an extension class, I need to call extend()
directly.
Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced by the `updateValidate` extension hook'); | |
Deprecation::noticeWithNoReplacment('5.4.0', 'Use extend("updateValidate") instead'); |
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.
Please also update the phpdoc and the changelog
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.
The updateValidate
hook does not exist in CMS 5, so we cannot give this recommendation.
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.
use extend() directly instead
then. The fact is that you can stop calling this method in 5 immediately - its replacement is the extend()
method. The change of extension hook method isn't really related to this method being deprecated.
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 understand how you'd use extend() directly in CMS 5, or at least why you would
The thing being replaced here has a bool + a Validator for params. The functionality that's replacing it in CMS 6 has a ValidationResult param instead.
Presumably you'd need to implement something sort of convoluted in CMS 5 for this to work ... only to then replace it straight away in CMS 6?
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 understand how you'd use extend() directly in CMS 5, or at least why you would
extendValidationResult()
is ultimately an abstraction around $this->extend('updateValidationResult', $result, $validator);
You can just call that directly.
In CMS 5 you'll get a deprecation warning if you're calling extendValidationResult()
. One way to silence that is to call extend()
directly instead of calling extendValidationResult()
.
In CMS 6 that will also be the solution - calling extend()
, since extendValidationResult()
will no longer exist. Just you'll be passing a different hook name and different args, which is not usually information we include in deprecation notice messages.
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.
Updated
72dabda
to
936ffe2
Compare
936ffe2
to
15683cf
Compare
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.
LGTM
Issue #11422