Hi,

This module has full integration with Webform module but does NOT work with Webform Calculator module.

See attached screenshot. I am using a Number field for the Sliders. The Formula field provided by Webform Calculator module work perfectly with the Number field. It does not work with Number field when I change the field type from Text Field to Slider in the Number field settings.

Seems like it should be a easy fix. Would greatly appreciate a patch or a solution.

Thanks!

CommentFileSizeAuthor
#6 Trigger-change-2564903-6.patch1.05 KBcolemanw
pcalcu.jpg29.47 KBsuperdorx
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

superduperdan created an issue. See original summary.

PetarB’s picture

Did you end up finding a solution to this?

rudam’s picture

Im having he same issue right now. Will post here the solution... (if I find any...)

dodge’s picture

Anyone had any luck getting this to work yet?

dodge’s picture

I think I see why this happens, but not sure of the best way to resolve it.

Looking at the HTML for the webform elements, the normal number elements have this structure in the "name" attribute:

submitted[number_1]

The sliders have this structure:

__sliderfield[submitted][slider_1][value]

So you can get the value of the "number_1" component by using the token {number_1}, but by using the {slider_1} token in the webform calculator formula, it's trying to get the value directly from the "slider_1" component, when really it needs to go down one more level to its "value" child.

colemanw’s picture

Looks to me like the problem is that this module (sliderfield) does not trigger the 'change' event when the value is changed. This means javascript will not work correctly for webform_calculator as well as webform core conditionals, and other integrations.
Here is a patch to fix it:

colemanw’s picture

Title: Does NOT work with Webform Calculator module » Does not fire change event when value is changed
Category: Support request » Bug report
Status: Active » Needs review
dodge’s picture

Thanks for creating the patch but unfortunately it doesn't seem to work, for me at least. I still get "Enter correct value for slider_1 to see result." in my calculation fields.

Maybe there's still something else going on...

dodge’s picture

Status: Needs review » Active
dodge’s picture

Status: Active » Needs work
Chyvakoff’s picture

Hi.

/*in file webform_calculator.js*/
/*this*/
          var selector = ''
                  + 'input[name$="[' + componentKey + ']"]' // Number, Single select
                  + ', '
                  + 'select[name$="[' + componentKey + ']"]' // Number, Single select
                  + ', '
                  + 'select[name$="[' + componentKey + '][]"]'// Multiple select
                  + ', '
                  + 'input:radio[name*="[' + componentKey + ']"]'// Radios, grid
                  + ', '
                  + '#edit-submitted-' + componentKey + ' input:checkbox' // Checkboxes
                  ;

/*replace to*/
          var selector = ''
                  + 'input[name$="[' + componentKey + '][value]"]' // Slider Field
                  + ', '
                  + 'input[name$="[' + componentKey + ']"]' // Number, Single select
                  + ', '
                  + 'select[name$="[' + componentKey + ']"]' // Number, Single select
                  + ', '
                  + 'select[name$="[' + componentKey + '][]"]'// Multiple select
                  + ', '
                  + 'input:radio[name*="[' + componentKey + ']"]'// Radios, grid
                  + ', '
                  + '#edit-submitted-' + componentKey + ' input:checkbox' // Checkboxes
                  ;


/*this*/
 // Number
      var componentValue = pf($('input:text[name$="[' + componentKey + ']"]').val(), formulaComponent.extra.separator, formulaComponent.extra.point);

/*replace to*/
 // Number
      var componentValue = pf($('input:text[name$="[' + componentKey + ']"]').val(), formulaComponent.extra.separator, formulaComponent.extra.point);
//SliderField
if (componentValue === null) {
        componentValue = pf($('input[name$="[' + componentKey + '][value]"]').val(), formulaComponent.extra.separator, formulaComponent.extra.point);
      }
zkrebs’s picture

Any updates? The patch doesn't seem to fix my problem.

Update: the code changes listed above, in addition to the patch, seem to solve the problem, but only if the formula field is on the same page!