diff -rupN webform/components/select.inc webformnew/components/select.inc --- webform/components/select.inc 2010-04-11 00:02:09.000000000 +0200 +++ webformnew/components/select.inc 2010-06-18 11:26:36.000000000 +0200 @@ -261,6 +261,7 @@ function _webform_render_select($compone '#required' => $component['mandatory'], '#weight' => $component['weight'], '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'], + '#webform_component' => $component, ); // Convert the user-entered options list into an array. diff -rupN 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); } }