Hi,

In the 4.x branch of Webform Module we have a new Conditionals feature that "may be used to hide or show certain components (or entire pages!) based on the value of other components".

Would be great to export these conditions with webform_share.

Thank you!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chertzog’s picture

Status: Active » Needs review

The conditional actions associated with Webform 7.x-4.x are already in the export, there was just nothing in the import process to accept and save them. adding the following line to webform_share_components_update_form_submit will import the conditional statements if they exist.

  $component['cid'] = $cid;
      $component['nid'] = $node->nid;
      $node->webform['components'][$cid] = $component;
    }
    
    $node->webform['conditionals'] = isset($webform['conditionals'])?$webform['conditionals']:array(); // <--THIS IS THE LINE THAT NEEDS TO BE ADDED.

    // If requested, re-add the existing components rather than allowing these
    // to be deleted. Existing cid values are safe to reuse.
    if (!empty($form_state['values']['keep_existing_components'])) {

It should be around line 157 of webform_share.module.

Note: this is a quick and dirty method. There should probably be some checking to make sure component IDs match up...

firfin’s picture

I think there should probably be cid matchup indeed. Not much though. I imported a webform with 20 conditionals only one of which had a mismatch on a component ID.
Unfortunately I do not seem to be able to produce a minimal testcase / reproduction of the problem.

jonhines’s picture

Issue summary: View changes

#1 works fine if you have not deleted any fields above the elements you are running conditions on. If you have deleted some webform fields, it will miss. I tried to use the above to move a form with 50+ conditional statements and 120+ conditional rules.

My content creator had deleted a field early on. Every field condition broke. I was able to update the source field in the webform_conditional_rules table via sql query but I eneded up having to manually set the targets in the webform_conditional field through the web admin interface. I don't intend to do that again.

I'll try making the matching work and submit a patch if I ever need this again but I'm probably just going to recommend that my content creators set conditional statements live in the near future.

scottrigby’s picture

#1 works when both import checkboxes are unchecked. This is all we need for now, so attaching a patch for tracking. If you need to check the CID on existing webforms, more work would need to be done.

ebanford’s picture

Tested #4 and it seems to work fine for this needed functionality.

Alan D.’s picture

Status: Needs review » Fixed

Committed.

Cheers

  • Alan D. committed 7098748 on 7.x-1.x authored by scottrigby
    Issue #1775452 by scottrigby, chertzog, Alan D.: Export the new...

Status: Fixed » Closed (fixed)

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