I have this posted on the webform conditionals issues but realized this is a webform pay issue. I was looking into why webform pay and webform conditionals did not work. I found that it was based on id's not being on the html for the webform pay fields. If you want you can read through the thread here: http://drupal.org/node/1142900. I have copied most of the issue below as well:

Someone suggested I use firebug to test for error. I am not seeing any javascript errors that are being thrown with firebug. In the tests that I have run it does not even seem to get the trigger on the form field. The option when building the form but its just not firing the javascript at all. Its as if the condition is never built.

Save the page then try this on the webform_conditional.js file:

Drupal.behaviors.webform_conditional.Matches = funciton(currentValues,triggerValues){
alert('current values: '+currentValues +' trigger value: '+triggerValues); <- this never fires. However on a different field with conditionals it fires just fine.

So somewhere its not building this into the form to look at the conditionals at all.

I did see that in the jQuery.extend(Drupal.settings the monitor_field_key is being set but I just don't see why its firing in the javascript.

#5
Posted by sandy.girl on August 19, 2011 at 5:15pm
Okay here is what I found. Its missing an id on the webform payment css. The top of the javascript mentions in the webform conditionals script css_id":"webform-component-payment-information"] yet this id is no where in the html. So I have added the id to the html on a static page I saved and it works. The condition fires fine and the form disappears.

so it needs to have id="webform-component-payment-information" added to the div class="pay-cc-info"

Does someone know how to create the patch?

Comments

theoracleprodigy’s picture

So not really knowing if I am following the standards for codding here is the fix I came up with the following changes. This is in the webform_pay.component.inc.

In the function _webform_render_components it is missing the #prefix and #suffix where you need to put in the id's. Usually that is written like so:

function _webform_render_component($component, $value = NULL) {
$form_item = array(
'#type' => 'textfield',
'#title' => $component['name'],
'#required' => $component['mandatory'],
'#weight' => $component['weight'],
'#description' => _webform_filter_descriptions($component['extra']['description']),
'#default_value' => $component['value'],
'#prefix' => '‹div class="webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '"›',
'#suffix' => '‹/div›',
);

However we are looking for webform-component-payment-information so I have had to hard code those values (mostly because the type comes in with an underscore as "payment_information" from the $component['type']. So here is my fix:

Add the following lines after line 220 '#webform_component' => $component,
'#prefix' => '‹div class="webform-component-payment-information" id="webform-component-payment-information"›',
'#suffix' => '‹/div›',

theoracleprodigy’s picture

Now the issue is that its all required fields... so it doesn't really work as a conditional "hidden" field.

quicksketch’s picture

Title: does not work with webform conditionals » Webform Pay missing normal Webform IDs and Classes (affecting Webform Conditionals)
Status: Active » Fixed
StatusFileSize
new1.61 KB
new1.72 KB

Thanks for the report. I don't directly support Webform Conditionals, but the fact that Webform Pay is missing the normal wrapper classes around its components may make it hard to theme (or in this case, manipulate with JavaScript).

In newer versions of Webform, we have standardized approaches to adding these classes through theme_webform_element_wrapper() theme function (or just theme_webform_element() in D7). These patches make it so that Webform Pay components have the same wrapper IDs and Classes as other Webform components. I've committed to both D6 and D7 branches.

Status: Fixed » Closed (fixed)

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

hootingsalmon’s picture

I receive an error when using webform pay and using webform conditionals. The pay field is set to display when someone selects from "credit card" from a select list containing various payment options. I receive an error indicating that credit card payment requires first name, last name, number, expiration date, etc even though I've selected other payment options and the pay fields with the various credit card information are not displaying.