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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stockliasteroid’s picture

bojanz’s picture

Status: Active » Needs review
torgosPizza’s picture

I 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.

gcb’s picture

Status: Needs review » Reviewed & tested by the community

I 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.

andyg5000’s picture

mglaman’s picture

Title: Pass $order object to alter hook » Pass form state to checkout pane alter hook

Updating title

  • mglaman committed 864c614 on 7.x-2.x authored by torgosPizza
    Issue #2188183 by stockliasteroid, torgosPizza, andyg5000, gcb: Pass...
mglaman’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, all!

torgosPizza’s picture

Woo! Thanks Matt.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.