Problem/Motivation
There are cases where the element will be marked as disabled client-side.
An example is a webform with conditions[1], and Conditional Logic, that mark the element as disabled
. This happens with the use of the data-drupal-states
property and as a result what is actually marked as disabled is the wrapper of the stripe element with the addition of the class form-disabled
In this case we have a form with the Stripe element still in place that should not be taken into account on submission.
Currently the Javascript part of the Stripe implementation intervenes, proceeds first with the Stripe call and then passes back the control to the form for continuing with the submission.
The Stripe element though should be ingored so the Stripe call should not take place.
[1]
https://www.drupal.org/docs/drupal-apis/form-api/conditional-form-fields β
Steps to reproduce
1. Create a webform and attach a Stripe element on it
2. Set a contitional logic that will mark this field as disabled
3. With the Stripe field disabled try to proceed with the webform submission.
The Stripe call takes place, and since the Credit Card field is empty comes back with an error message (validation) that prevents to webform for being submitted.
The above could be a real case when we have a webform where the user selects the payment method
1. [ ] Bank/wire Transfer
2. [ ] Credit Card
In the case of the credit card we display the Stripe fields and make it mandatory for the sumbission of the webform. The submission requires a succesfull charge.
In the case of the Bank Transfer we mark the "Stripe" fieds as disabled and we let the user submit the webform.
Proposed resolution
In stripe.js
we check the stripe element and if it is wrapped with the form-disabled
class we cancel the related logic and return the control back to the form.
Remaining tasks
User interface changes
API changes
Data model changes