When I use the grid form element and set it to mandatory, the user can pass by the question without filling it in with no errors. The mandatory feature doesn't seem to work on the grid form elements.

Has anyone else found this to be the case?

CommentFileSizeAuthor
#5 webform_grid_required.patch1.11 KBquicksketch

Comments

Eldeem’s picture

Yes, I've just found this problem too. My form mostly consists of grid components, so it's very inconvenient.
Subscribing.

Eldeem’s picture

Can anyone please help me with this issue? It causes me a lot of trouble.
I've tried looking into it for the past few days, but I'm still new to Drupal so I couldn't figure it out.

Thanks.

quicksketch’s picture

I'll have a look at this when I'm next available to work on Webform, however I've got a few pressing tasks to look at before I have time. The problem almost certainly is located in the includes/grid.inc file, somewhere in the _webform_render_grid() function.

Eldeem’s picture

Thank you, quicksketch.
It seems that the issue caused by following part of _webform_render_grid() function:

 foreach ($questions as $key => $question) {
    if ($question != '') {
      $element[$key] = array(
        '#title'         => $question,
        '#required'      => $component['mandatory'],
        '#options'       => $options,
        '#type'          => 'radios',
        '#process'       => array('expand_radios', 'webform_expand_select_ids'),
        '#validated'     => TRUE, // Webform handles validation separately.
      );
    }

Deleting '#validated'-part helps, but there is at least one side effect. I have a multi-page form and removing this string causes #588354: no validation for prev button issue. Any ideas?

quicksketch’s picture

Status: Active » Fixed
StatusFileSize
new1.11 KB

I've committed this patch which should fix both the required problem and not re-introduce a previous-page button problem.

roball’s picture

Thanks for the fix. I also observed the problem and can confirm it is now fixed in the latest 6.x-3.x-dev. Nice to see you got back to continue getting forward to a 6.x-3.0 release.

boftx’s picture

I applied the patch to 6.x-3.0-beta5 and it corrected the problem.

Eldeem’s picture

The patch works great! Thank you, quicksketch.

Status: Fixed » Closed (fixed)

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