Closed (fixed)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 Aug 2011 at 02:08 UTC
Updated:
26 Jul 2018 at 03:17 UTC
Jump to comment: Most recent
Comments
Comment #1
quicksketchWebform does not provide any ability to do calculations, though you can of course export your results into a CSV or Excel file and do any calculations or reports from there.
Webform already does a few calculations for you (such as around grid and select components) under the Results -> Analysis tab, but these analysis options are not user-modifiable.
Comment #2
vernond commented@botser - if you have capacity to do a D6 local install I would be most grateful if you could test-drive the module posted here: http://drupal.org/node/1251902
In order to take it further I'm going to need wide ranging feedback to help decide where to go. It doesn't currently support grids, but any input on what is currently supported would be appreciated.
Comment #3
botser commented@vernond I would be happy to test-drive your new module, and feedback you ASAP
Webform is great, but this function is missing for me.
Comment #4
jboeger commentedI would also very much like this function... calculate in hidden webform fields.
Comment #5
firfin commentedIt is probably my fault, but I had high expectations of webform in this regard. Giving some feedback seems fairly essential to most (non-survey) webforms.
I got especially excited about 'webform conditionals' in this regard. Don't get me wrong, it works great for hiding / showing parts of a questionnaire. Unfortunately that seem to be the only possibility (setting visibility of components?) Also the only operand seems to be checking for set-inclusion? Hopefully I am mistaken here and webform (conditionals) is capable of more?
I would for instance like to be able to hide/show component based on numerical comparison (i.e. 'If A >30' or 'if A +B < 50' ) This is not a very exotic use-case imho.
Am I understanding correctly that webform is more of a 'one way stream' ? There is no way to give ( calculated / computed / intermediate ) feedback to users? Or to do any calculations at all?
If so, what other module would you suggest to create a more interactive experience than just gathering answer to questions?
Or is there some way to extend webform that I am missing?
p.s. I know about the existence of webform macro.
Comment #6
quicksketchWebform has pretty much all the limitations you described. The conditional system is more flexible in the 4.x branch, but it's still centered around showing and hiding fields, and it doesn't have any support for mathematics.
Yes, as described on the handbook page: http://drupal.org/documentation/modules/webform#webform-vs-cck
You'd need to be more specific with your request. If you're looking for "an arbitrary form builder to do arbitrary conditions and fire arbitrary actions", that's quite a tall order. My guess is that Rules module would probably fit somewhere in the solution, but its clunky interface would probably make it difficult to implement a complex form.
Webform may be the best starting point for what you're hoping to find, but its abilities to do all you're asking for aren't implemented. My guess is that for the short-term, a completely custom form coded by hand is probably the easiest way forward.
Comment #7
quicksketchActually thinking about this from the perspective of add-on modules (I don't think Webform Macro would work for this), something like http://drupal.org/project/webform_calculator could potentially accomplish these things. Considering the 4.x branch can do conditionals based on multiple components, you could use the formula component to do the math, then do the condition based off that formula component.
As for giving feedback to users, the 4.x branch also lets you reference the submission as tokens in the confirmation message. Ideally we'd be able to do this during the form also if your form had multiple pages. That's a feature request over here: #1672890: Access submission data tokens from earlier pages in markup components
So basically still I don't think there's an easy way to do calculations. Though it's possible to extend Webform to do these calculations, I'm not aware of a project that has provided this functionality in an easy to use way.
Comment #8
firfin commentedThanks for your clear answers quicksketch (and the great module of course ;-) )
The mailing part and of course the amazingly intuitive to use (4.x) conditionals are two of the main reasons why I started this project using webform. I have done some simple calculations based of webform in the past. I thought this functionality would have been expanded too.
Then again, I probably abused webform_php for accomplishing that.
Thank you for setting me straight on webform.
I will push on trying to accomplish this utilizing webform. I really love the conditionals so far, especially for 'branching' questions. This will be hard for me to accomplish using other modules or coding by hand. The main thing missing for me is the ability to display feedback (see bottom of this comment.) Often this is based on calculations.
The "webform_calculator combined with conditionals" approach is very appealing to me. I will probably try that route first. (this of course requires Webform 4.x , setting version accordingly)
The "Access submission data tokens" looks very promising too. I will definitively be chipping in there over the coming weeks.
This might be considered going off-topic, but to be more specific (as in use-case).
I am building an in-depth online financial gains analysis tool for buying solarpanels )specifically aimed at businesses (with their own roofs.)
Input range from roof-width and -height, geolocation, amperage of mains, energy consumption, gross profits. The first two are used to calculate available area. Area's used to calculate how many panels can be placed. Number of panels to get a theoretical 'watt-peak'. This again is used for a realistic estimate based on gelocation. This may not be higher than amperage. Finally some calculations need to be done to see how much tax deduction I company can get from investing. Some other financials are calculated.
Based on the results, the user would then be able to request price quotes from 'fitting' vendors.
On paper / spreadsheet I had all inputs and resulting calculated values spread over 8 pages. With webform conditionals I have been able to squeeze it into 4 pages. There was a lot of branching in the questions. Great stuff! Just no intermediate feedback (based on your roof size you can place N panels). Or numerical branching ( panels possible on roof > amperage allowed on mains.)
Comment #9
quicksketchConsidering the amount of math you're doing, you might try a hybrid approach of using Webform + hook_form_alter() in a custom module. I've built lots of forms where the functionality was tweaked slightly. Adding additional submit handlers can allow you to replicate the functionality of Webform PHP, but without the dirtiness/dangeriousness of storing PHP code in the database. There's a handbook page on this topic already: http://drupal.org/node/1291574
Comment #10
firfin commentedThanks for confirming my thought that a combination of webform and a custom module is probably the way to go. The link you provided will probably prove invaluable. I assume it is still correct for webform 4.x.
It will take quite a bit of coding. Like you said there is a considerable amount of calculation to be done. :-) I will still be looking into your two earlier suggestions, hopefully they will be able to serve my needs for the simpler feedback calculations (of which they are plenty).
Comment #11
quicksketchYep the docs work for both 3.x and 4.x (it's actually the same for D6 and D7 too, which is unusual in the world of Drupal).
Comment #12
quicksketchClosing after lack of activity. As a built-in feature, this isn't on the roadmap for the main project.
Comment #13
rafalenden commentedYou can try https://www.drupal.org/project/webform_calculator
Comment #14
arctushar commentedWe need some math functions outside of only +-*/% ,
I need power and root of numbers.
Comment #15
vunda commentedWe need more power, calculating the # fields would be great. I'm running Drupal 8.
Thank you!
Comment #16
millionleaves commentedI haven't tried this yet, but it looks like Webform 5 for D8 can now handle this:
https://www.drupal.org/project/webform/issues/2864843
Mentioning in case @vunda is still looking for a solution, and for anyone else who finds this thread first (as I did).