In function webform_validation_validate() you get the keys of the values array_keys($form_state['values']['submitted']);.
All is perfect when the field is on the first level (example Code: $form_state['values']['submitted']['field']), but if a field is inside a fieldset (example Code: $form_state['values']['submitted']['fieldset']['field']); or deeper. Then you get the key of a fieldset with array_keys($form_state['values']['submitted']); and the check with

if (!in_array($element_id, $current_page_components)) {
          unset($rules[$ruleid]);
        }

fails for those fields.

CommentFileSizeAuthor
#3 webform_validation_833500.patch1.5 KBtobiasb

Comments

svendecabooter’s picture

Assigned: Unassigned » svendecabooter

Do you use webform 2 or 3?
I could have sworn this worked, but I think I also tried this with webform 2.
I'll have to go back and run some tests for this when I find some time.

tobiasb’s picture

Webform 3.x, sorry forgot it. element_children() should the right way and perhaps a recursive function with a static $variable.

tobiasb’s picture

Status: Active » Needs review
StatusFileSize
new1.5 KB

Ok, with this patch it should work now.

svendecabooter’s picture

Assigned: svendecabooter » Unassigned
Status: Needs review » Fixed

Hi tobiasb,

Thanks a lot for contributing your patch!
From your original message I didn't understand that the problem was related to fieldsets in multipage forms.
I tested your patch with various types of forms, and the code seems to make absolutely sense, so i committed it.

Thanks again for finding this problem

svendecabooter’s picture

Status: Fixed » Closed (fixed)
Greg Varga’s picture

Version: 6.x-1.2 » 6.x-1.3
Status: Closed (fixed) » Needs work

I found a bug in tobiasb's fix.

Sorry, I can't create fancy patches (I will learn I promise!:), but here is the code:

webform_validation.module (version = 6.x-1.3)

ORIGINAL VERSION: line 112-117

  if ($version == 2) {
    $page_count = isset($form_state['values']['details']['page_count']) ? $form_state['values']['details']['page_count'] : NULL;
  }
  elseif ($version == 3) {
    $page_count = isset($form_state['webform']['page_count']) ? $form_state['webform']['page_count'] : NULL;
  }

UPDATED VERSION: line 112-120

  if ($version == 2) {
    $page_count = isset($form_state['values']['details']['page_count']) ? $form_state['values']['details']['page_count'] : NULL;
  }
  elseif ($version == 3) {
    $page_count = isset($form_state['webform']['page_count']) ? $form_state['webform']['page_count'] : NULL;
    if(!$page_count){
      $page_count = isset($form_state['storage']['page_count']) ? $form_state['storage']['page_count'] : NULL;
    }
  }

One step > 1 the $form_state root key changes from "webform" to "storage" so in tobiasb's fix the page number never loads. In the new code, we double check the page number using the new form key.

This bug http://drupal.org/node/996894 is a duplicate of this same issue.

I hope this helps. Let me know if anything is not clear or if I am talking rubbish! :)

Cheers,
Gergely Varga
http://42droids.co.uk

FreeFox’s picture

Status: Needs work » Reviewed & tested by the community

With the last modification it works like a charm. Thanks a lot Gergely.

Please commit

umberto.’s picture

It works for me too (6.x-1.3).

Thanks a lot

svendecabooter’s picture

The $page_count issue has been addressed now.
If possible, please git clone the 6.x-1.x branch and check if that version resolves your problems correctly.

svendecabooter’s picture

Component: Validation rules » Code
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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