Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
#2311393: Remove hook_element_info() and all references to it replaced hook_element_info with plugins, but there's a todo left in the code
// @todo Once all elements are converted to plugins in
// https://www.drupal.org/node/2311393, rely on
// $element['#value_callback'] directly.
Proposed resolution
Remove dynamic value callback of form form_type_TYPE_value
Remaining tasks
Review
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#15 | 3221798-15.patch | 1.98 KB | pradhumanjain2311 |
| |||
#2 | 3221798.patch | 967 bytes | larowlan |
|
Comments
Comment #2
larowlanComment #3
mstrelan CreditAttribution: mstrelan at PreviousNext for Service NSW commentedPatch does exactly as per the @todo that it removes, the blocker is fixed and the tests are passing. LGTM.
Comment #4
guilhermevp CreditAttribution: guilhermevp at CI&T commentedI agree with @mstrelan, the blocker is done and so is the @todo, all are green there is nothing much left to say other than RTBC.
Comment #5
tim.plunkettMy first instinct is that the FormElement::valueCallback should be used instead of NULL. But currently this code protects against someone setting a non-callable as the #value_callback, and while that should be happening, it's probably not worth removing the protection.
So unless someone else disagrees, I think this is a great change.
Comment #6
Eric_A CreditAttribution: Eric_A at Dutch Open Projects commentedform_type_checkboxes_value()
in other files. I'm not sure if those are being tackled elsewhere or not. And if fixing those is in scope here or not.Comment #7
larowlanYeah I think fix that here
http://grep.xnddx.ru/search?text=form_type_TYPE_value&filename= yields no references to the hook name, but that's not really telling us much.
So perhaps we should be triggering a deprecation notice now, and then removing in D10?
@tim.plunkett thoughts?
Comment #10
tunicCurrently, Drupal 9.4.1 ha only two references to form_type_checkboxes_value and they are inside comments:
Drupal\Core\Command\InstallCommand:
Drupal\Core\Test\FunctionalTestSetupTrait:
So I guess that's not a concern anymore.
Comment #12
smustgrave CreditAttribution: smustgrave at Mobomo commentedI think it would be nice to have a deprecation just in case someone has custom code. Better safe then sorry
Comment #14
alexpottI don't think we need to do a deprecation dance here - see http://grep.xnddx.ru/search?text=function+form_type_&filename= all the calls here would be broken due to the core functions no longer existing.
We do need to update the document in \Drupal\Core\Form\FormBuilderInterface::doBuildForm() though as this says:
Comment #15
pradhumanjain2311 CreditAttribution: pradhumanjain2311 at OpenSense Labs for DrupalFit commentedMade changes as per comment #14.
Comment #16
FatherShawnThanks @larowan. I fixed this before I saw your comment in the course of working on #value_callback in #2966711: Limit what can be called by a callback in form arrays and did it just as you did in your patch. My only difference is the stated default. The logic of the code sets the default to
\Drupal\Core\Render\Element\FormElement::valueCallback
. I'll leave a comment on the other issue and perhaps we can close them together?Comment #17
smustgrave CreditAttribution: smustgrave at Mobomo commentedTalking in slack wtih @FatherShawn and the two tickets do overlap but think we agreed this could probably land first (or has a better shot of it) while the larger task of #2966711: Limit what can be called by a callback in form arrays is worked on.
Comment #18
longwaveNot sure what this sentence is trying to say. I think we can just say something like:
Comment #19
alexpottDiscussed with @longwave and the change from form_type_* functions to valueCallback is part of https://www.drupal.org/node/2320115 - a very old CR indeed!
Going fix the comment on commit (after discussing with @longwave).
Comment #20
alexpottCommitted and pushed 5cbb5c9f46f to 11.x and 884929d80ba to 10.2.x. Thanks!