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.
Steps to reproduce:
- Configure a checkout page with payment methods pane, billing address pane or coupon pane. In theory the error should happen with other panes that sent AJAX requests.
- Select a payment method other than first default option.
- Interact with other pane that sent an AJAX request E.g. change country from addressfield.
- Submit the checkout page.
- Validation error for the first default option payment method avoid submission.
(Attached are screenshots to reproduce the error)
Comments
Comment #1
citlacom CreditAttribution: citlacom commentedHere is the solution I suggest.
Comment #3
rszrama CreditAttribution: rszrama commentedI don't generally like to use $form_state['input'] if I can avoid it. We use #limit_validation_errors when the country select list is changed, and that means the value in $form_state['input'] may actually be a non-existent payment method. I'm not certain someone could use that to their advantage, but I'd rather not give 'em the chance; it doesn't appear our validate handler does any check to make sure the payment method value is an "allowed" value, for example.
The attached patch seems to address the problem, though, by first looking in the validated values array and if nothing is found looking to see if there is a payment method value in the input array. If so, we use the #default_value from the $form_state['complete form'], which at this point in time would be the last rendered selection. In testing, it appears to have solved the reported issue and doesn't seem to cause any regression.
Comment #4
rszrama CreditAttribution: rszrama commentedCommitting that.