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.
Just a quick change here... I'm altering the payment checkout form via the excellent and forward thinking commerce_cardonfile_checkout_pane_form_alter hook, but in my callback I'd like to have the $order object as well. It's not available on any of the $form arrays passed to that alter call, so this small patch grabs it out of the $form_state array and passes it as the third argument to the alter.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2188183-cardonfile-alter-3.patch | 616 bytes | torgosPizza |
#1 | 2188183_commerce_cardonfile_alter.patch | 625 bytes | stockliasteroid |
Comments
Comment #1
stockliasteroid CreditAttribution: stockliasteroid commentedComment #2
bojanz CreditAttribution: bojanz commentedComment #3
torgosPizzaI ran into this today too, and I propose we send both $form and $form_state to the alter hook, since $form_state will also include the $order object, as well as the $account and any potential form data sent via POST (such as when a new Card on File is selected).
Attached is a patch which does this. It's hugely important to pass in $form_state because without it we have no idea whether any implementations of commerce_cardonfile_checkout_pane_form_alter() are reacting on default data, or data that has been changed/updated as part of an ajax refresh or other type of post from a form.
Comment #4
gcbI am using this patch, and I need the same thing. Passing along $form_state seems not only sensible but standard behavior for altering of forms.
Comment #5
andyg5000+1. do it!
Comment #6
mglamanUpdating title
Comment #8
mglamanThanks, all!
Comment #9
torgosPizzaWoo! Thanks Matt.