Commit 0f540e11 authored by mattwire's avatar mattwire

Fix webform detection so it doesn't generate a false positive if we also have...

Fix webform detection so it doesn't generate a false positive if we also have a webform on the same page
parent 391ce433
...@@ -185,7 +185,7 @@ CRM.$(function($) { ...@@ -185,7 +185,7 @@ CRM.$(function($) {
} }
}); });
var isWebform = getIsWebform(); var isWebform = getIsWebform($form);
// For CiviCRM Webforms. // For CiviCRM Webforms.
if (isWebform) { if (isWebform) {
...@@ -222,7 +222,7 @@ CRM.$(function($) { ...@@ -222,7 +222,7 @@ CRM.$(function($) {
return false; return false;
} }
var isWebform = getIsWebform(); var isWebform = getIsWebform($form);
// Handle multiple payment options and Stripe not being chosen. // Handle multiple payment options and Stripe not being chosen.
if (isWebform) { if (isWebform) {
...@@ -341,17 +341,19 @@ CRM.$(function($) { ...@@ -341,17 +341,19 @@ CRM.$(function($) {
} }
} }
function getIsWebform() { function getIsWebform(form) {
return $('.webform-client-form').length; // Pass in the billingForm object
// If the form has the webform-client-form class then it's a drupal webform!
return form.hasClass('webform-client-form');
} }
function getBillingForm() { function getBillingForm() {
// If we have a stripe billing form on the page // If we have a stripe billing form on the page
var $billingForm = $('input#stripe-pub-key').closest('form'); var $billingForm = $('input#stripe-pub-key').closest('form');
if (!$billingForm.length && getIsWebform()) { //if (!$billingForm.length && getIsWebform()) {
// If we are in a webform // If we are in a webform
$billingForm = $('.webform-client-form'); // $billingForm = $('.webform-client-form');
} //}
if (!$billingForm.length) { if (!$billingForm.length) {
// If we have multiple payment processors to select and stripe is not currently loaded // If we have multiple payment processors to select and stripe is not currently loaded
$billingForm = $('input[name=hidden_processor]').closest('form'); $billingForm = $('input[name=hidden_processor]').closest('form');
...@@ -361,7 +363,7 @@ CRM.$(function($) { ...@@ -361,7 +363,7 @@ CRM.$(function($) {
function getBillingSubmit() { function getBillingSubmit() {
$form = getBillingForm(); $form = getBillingForm();
var isWebform = getIsWebform(); var isWebform = getIsWebform($form);
if (isWebform) { if (isWebform) {
$submit = $form.find('[type="submit"].webform-submit'); $submit = $form.find('[type="submit"].webform-submit');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment