Skip to content
Snippets Groups Projects
Commit e6319a2f authored by mattwire's avatar mattwire
Browse files

Handle previous/submit buttons on drupal webform

parent 22a12d65
No related branches found
No related tags found
No related merge requests found
......@@ -8,13 +8,15 @@ Latest releases can be found here: https://civicrm.org/extensions/stripe-payment
View this extension in the [Extension Directory](https://civicrm.org/extensions/stripe-payment-processor).
## Compatibility / Requirements
* CiviCRM 5.10+
* PHP 7.0+
* CiviCRM 5.13+
* PHP 7.1+
* Jquery 1.10 (Use jquery_update module on Drupal).
* Drupal 7 / Joomla / Wordpress (latest supported release). *Not currently tested with other CMS but it may work.*
* Stripe API version: 2019-02-19
* Stripe API version: 2019-08-14
* Drupal webform_civicrm 7.x-4.22+ (if using webform integration)
If using test mode with drupal webform_civicrm you need this patch: https://github.com/colemanw/webform_civicrm/pull/266
## Credits
Current Maintainer: Matthew Wire - https://www.mjwconsult.co.uk
......
......@@ -249,17 +249,14 @@ CRM.$(function($) {
// For CiviCRM Webforms.
if (getIsDrupalWebform()) {
// We need the action field for back/submit to work and redirect properly after submission
if (!($('#action').length)) {
form.append($('<input type="hidden" name="op" id="action" />'));
}
var $actions = form.querySelector('[type=submit]');
$('[type=submit]').click(function() {
$('#action').val(this.value);
addDrupalWebformActionElement(this.value);
});
// If enter pressed, use our submit function
form.addEventListener('keydown', function (e) {
if (e.keyCode === 13) {
$('#action').val(this.value);
addDrupalWebformActionElement(this.value);
submit(event);
}
});
......@@ -453,4 +450,19 @@ CRM.$(function($) {
}
}
function addDrupalWebformActionElement(submitAction) {
var hiddenInput = null;
if (document.getElementById('action') !== null) {
hiddenInput = document.getElementById('action');
}
else {
hiddenInput = document.createElement('input');
}
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'op');
hiddenInput.setAttribute('id', 'action');
hiddenInput.setAttribute('value', submitAction);
form.appendChild(hiddenInput);
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment