I need to calculate based on selection (show and hide using conditional, see the attachment)
It looks ok, the formula result can be displayed. However when it is submitted, it cannot be saved in the database.

CommentFileSizeAuthor
form3.PNG8.7 KBwaluyo.umam
form2.PNG12.96 KBwaluyo.umam
form1.PNG3.26 KBwaluyo.umam
form.PNG2.43 KBwaluyo.umam

Comments

Snehal Brahmbhatt’s picture

Hi,

You have to use hook_webform_submission_presave() to set default value of form element.

Create custom module and place following code into your custom module file. Check its working fine.

/**
* Implements hook_webform_submission_presave().
*/
function custom_webform_submission_presave($node, &$submission) {
   if($submission->data[1][0] == 'A') {
           $submission->data[3][0] = 0;        # Set Default Value of Variable A
   }
   else if($submission->data[1][0] == 'B') {
           $submission->data[2][0] = 0;        # Set Default Value of Variable B
   }
} 

Let me know if you face any further query/concern regarding this.

Thanks,
Snehal Brahmbhatt | AddWeb Solution
https://www.drupal.org/user/3147795/track

colemanw’s picture

Category: Bug report » Support request
Status: Active » Fixed

Status: Fixed » Closed (fixed)

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