Common subdirectories: webform/components and webformnew/components Common subdirectories: webform/css and webformnew/css Common subdirectories: webform/images and webformnew/images Common subdirectories: webform/includes and webformnew/includes Common subdirectories: webform/js and webformnew/js Common subdirectories: webform/templates and webformnew/templates Common subdirectories: webform/tests and webformnew/tests Common subdirectories: webform/translations and webformnew/translations Common subdirectories: webform/views and webformnew/views diff -upN webform/webform.module webformnew/webform.module --- webform/webform.module 2010-04-11 08:13:51.000000000 +0200 +++ webformnew/webform.module 2010-06-18 10:01:39.000000000 +0200 @@ -1013,7 +1013,6 @@ function webform_node_load($node) { $component['mandatory'] = $c['mandatory']; $component['pid'] = $c['pid']; $component['weight'] = $c['weight']; - webform_component_defaults($component); } @@ -1604,6 +1603,27 @@ function webform_client_form_validate($f } /** + * Recursive method to find the parent in a multidimensional array. + */ +function find_parent($index, $array, $needle, $parent = null) { + foreach ($array as $key => $value) { + if (is_array($value)) { + $pass = $parent; + if (is_string($key)) { + $pass = $key; + } + $found = find_parent($index, $value, $needle, $pass); + if ($found !== false) { + return $found; + } + } else if ($key == $index && $value === $needle) { + return $parent; + } + } + return false; +} + +/** * Recursive validation function to trigger normal Drupal validation. * * This function imitates _form_validate in Drupal's form.inc, only it sets @@ -1618,6 +1638,20 @@ function _webform_client_form_validate($ // Recurse through all children. foreach (element_children($elements) as $key) { if (isset($elements[$key]) && $elements[$key]) { + if(!empty($elements[$key]['#webform_component']['extra']['webform_conditional_field_key'])){ + $veldnaam = $elements[$key]['#webform_component']['extra']['webform_conditional_field_key']; // Van welk veld het veld afhankelijk is. + $veldwaarde = $elements[$key]['#webform_component']['extra']['webform_conditional_field_value']; // Wat verwacht wordt als hij dependent is + $index = find_parent($veldnaam, $elements['#post']['submitted'], $veldwaarde); // Krijg het juiste fieldset als het veld zich binnen een fieldset bevindt + if(!empty($index)){ + $veldwaarde_submitted = $elements['#post']['submitted'][$index][$veldnaam]; // Wat gebruiker gekozen heeft + } + else{ + $veldwaarde_submitted = $elements['#post']['submitted'][$veldnaam]; // Wat gebruiker gekozen heeft + } + if($veldwaarde != $veldwaarde_submitted){ // Als het verwachte antwoord NIET overeenkomt wat gekozen is, is het veld NIET verplicht. + $elements[$key]['#required'] = 0; + } + } _webform_client_form_validate($elements[$key], $form_state, FALSE); } }