I have a form with two main conditions off a select field: Condition 1, Condition 2.
I created questions for each condition such that:
Condition 1: Question 1; Question 2
Condition 2: Question 3; Question 4*

If one of these questions is a grid and mandatory AND the non-triggering condition is selected, the question is still required. If the questions are not the type grid, the webform works as expected.

For example, if question 4 is a grid and mandatory and I choose condition 1 from the select list, upon submitting the form, I'm still required to complete question 4.

Thanks for a great module!

Comments

tedbow’s picture

If you could export a non-working example webform using Node Export and upload the export here that would speed up my testing.
Thanks,
Ted

tedbow’s picture

Status: Active » Postponed (maintainer needs more info)

I am going to postpone this until I get an example Webform export or at list a url to one.
Thanks

mfkahn’s picture

Here's one. Steps to reproduce: 1) import/create this form; 2) View form; 3) Click Submit -- submit will fail because of mandatory grid inside of hidden fieldset.

array(
  'nid' => '15',
  'type' => 'webform',
  'language' => 'en',
  'uid' => '1',
  'status' => '1',
  'created' => '1303569580',
  'changed' => '1303569580',
  'comment' => '2',
  'promote' => '1',
  'moderate' => '0',
  'sticky' => '0',
  'tnid' => '0',
  'translate' => '0',
  'vid' => '25',
  'revision_uid' => '1',
  'title' => 'Example for http://drupal.org/node/1084760',
  'body' => '<p>Demonstrates problem with in-page conditionals and grids.</p>',
  'teaser' => '<p>Demonstrates problem with in-page conditionals and grids.</p>',
  'log' => '',
  'revision_timestamp' => '1303569580',
  'format' => '1',
  'name' => 'admin',
  'picture' => '',
  'data' => 'a:0:{}',
  'path' => 'content/example-httpdrupalorgnode1084760',
  'webform' => array(
    'nid' => '15',
    'confirmation' => '',
    'confirmation_format' => '1',
    'redirect_url' => '<confirmation>',
    'status' => '1',
    'block' => '0',
    'teaser' => '0',
    'allow_draft' => '0',
    'auto_save' => '0',
    'submit_notice' => '1',
    'submit_text' => '',
    'submit_limit' => '-1',
    'submit_interval' => '-1',
    'record_exists' => TRUE,
    'roles' => array(
      '0' => '1',
      '1' => '2',
    ),
    'emails' => array(),
    'components' => array(
      '1' => array(
        'nid' => '15',
        'cid' => '1',
        'form_key' => 'show_fieldset_with_grid',
        'name' => 'Show Fieldset with grid',
        'type' => 'select',
        'value' => 'N',
        'extra' => array(
          'description' => 'Select "Yes" to show a same-page fieldset that is conditional, and contains a mandatory grid',
          'items' => 'Y|Yes
N|No',
          'multiple' => 0,
          'title_display' => 0,
          'aslist' => 0,
          'optrand' => 0,
          'conditional_operator' => '=',
          'other_option' => NULL,
          'other_text' => 'Other...',
          'custom_keys' => FALSE,
          'options_source' => '',
          'conditional_component' => '',
          'conditional_values' => '',
        ),
        'mandatory' => '1',
        'pid' => '0',
        'weight' => '0',
        'page_num' => 1,
      ),
      '2' => array(
        'nid' => '15',
        'cid' => '2',
        'form_key' => 'the_fieldset',
        'name' => 'The Fieldset',
        'type' => 'fieldset',
        'value' => '',
        'extra' => array(
          'description' => 'Here is a fieldset with a condition - the previous question has to have a value of "Y" to show it.',
          'title_display' => 0,
          'collapsible' => 0,
          'collapsed' => 0,
          'webform_conditional_field_value' => 'Y',
          'webform_conditional_cid' => '1',
          'webform_conditional_operator' => '=',
          'conditional_component' => '',
          'conditional_operator' => '=',
          'conditional_values' => '',
        ),
        'mandatory' => '0',
        'pid' => '0',
        'weight' => '1',
        'page_num' => 1,
      ),
      '3' => array(
        'nid' => '15',
        'cid' => '3',
        'form_key' => 'the_grid',
        'name' => 'The Grid, the Bad and the Ugly',
        'type' => 'grid',
        'value' => '',
        'extra' => array(
          'description' => 'Shows a grid that is mandatory.  When the first select is "N", the surrounding fieldset will hide this component, but the in-page conditional will still make it required.',
          'options' => 'good|Good
bad|Bad
ugly|Ugly',
          'questions' => 'thoseWithGuns|Those with guns
thoseWhoDig|Those who dig',
          'title_display' => 0,
          'optrand' => 0,
          'qrand' => 0,
          'custom_option_keys' => 0,
          'custom_question_keys' => 0,
          'conditional_component' => '',
          'conditional_operator' => '=',
          'conditional_values' => '',
        ),
        'mandatory' => '1',
        'pid' => '2',
        'weight' => '2',
        'page_num' => 1,
      ),
    ),
  ),
  'last_comment_timestamp' => '1303569580',
  'last_comment_name' => NULL,
  'comment_count' => '0',
  'taxonomy' => array(),
  'files' => array(),
  'menu' => array(
    'link_title' => '',
    'mlid' => 0,
    'plid' => 0,
    'menu_name' => 'primary-links',
    'weight' => 0,
    'options' => array(),
    'module' => 'menu',
    'expanded' => 0,
    'hidden' => 0,
    'has_children' => 0,
    'customized' => 0,
    'parent_depth_limit' => 8,
  ),
  '#_export_node_encode_object' => '1',
)

mfkahn’s picture

Update: this is probably more related to the webform clientside_validation addon module, though there is likely still a problem in this module too.

To workaround on the client side, use the jquery_update module and switch to jquery 1.4.4 or higher (did not test with older). Thin in clientside_validation.js, change the following around line 45:

self.validators[f] = $('#' + f).validate({
ignore: ':hidden',
errorClass: 'error',
errorContainer: '#' + errorel,
errorLabelContainer: '#' + errorel + ' ul',
wrapper: 'li'
});

The reason you need the jquery update is the :hidden selector in newer versions will match invisible elements as well as input type hidden elements, and thus not run the validator on anything that is not present on the screen.

However, the backend still returns an error on submit.

attiks’s picture

I created an issue for this in the clientside_validation, will have a look at it asap #1137490: Conditional grids problem (1084760)

jelle_s’s picture

Testing revealed clientside validation does it "the right way", meaning hidden required fields are not validated after submission. However, the server-side validation of webform conditional does not let this pass. Is this a bug or does it work by design?