I just updated to Webform 4.7, and was doing some edge case testing on my new site. My mandatory fields were no longer that, the form was accepted without entering any data.

I rolled back to both Webform 4.5 and 4.6 and got mandatory field errors on my webform.

As a test, I tried creating a new webform with a single mandatory test field. It correctly rejected the form submission.

I then cloned my original webform and removed components and disabled settings until the error went away.

It looks like the difference is having a preview page on the form setting. If you turn it on, the form is accepted without mandatory fields.

As a final test, I created a new webform, with a single mandatory field, and enabled the preview page in the form settings, and then submitted a blank form. The form was accepted. I then rolled webform back to 7.x-4.5, and the form was correctly rejected.

Comments

  • DanChadwick committed 67ca10c on 7.x-4.x
    Issue #2460401 by DanChadwick: Enabling preview page breaks required...
  • DanChadwick committed dd95f06 on 8.x-4.x
    Issue #2460401 by DanChadwick: Enabling preview page breaks required...
danchadwick’s picture

Status: Active » Fixed
Issue tags: -Preview page, -mandatory fields
StatusFileSize
new912 bytes
new912 bytes

Confirmed.

Committed to 7.x-4.x and 8.x.

If you want this fixed for production, I suggest you apply this patch. Conditionals have changed quite a lot since 4.7 and I would like to see them tested more before release. I have confirmed that this patch will apply cleanly to 4.7.

Or apply it by hand. In weborm.module, function webform_client_form_validate, change

  if ($form_state['webform']['preview']) {
    // Form has already passed validation and is on the preview page.
    return;
  }

to

  if ($form_state['webform']['preview'] && $form_state['webform']['page_count'] === $form_state['webform']['page_num']) {
    // Form has already passed validation and is on the preview page.
    return;
  }

danchadwick’s picture

Version: 7.x-4.7 » 7.x-4.x-dev
trevorbradley’s picture

Status: Fixed » Reviewed & tested by the community

Upgraded back to webform-7.x-4.7 and applied webform-required_preview-2460401-1.patch

Tried resubmitting my original webform with the preview intact. I get five wonderful ": field is requried" error messages.

Good work Dan. Thanks for the fast turnaround.

danchadwick’s picture

Status: Reviewed & tested by the community » Fixed

Already committed so status of Fixed is correct.

trevorbradley’s picture

Gotcha. I'll watch for the status in the future.

Status: Fixed » Needs work

The last submitted patch, 2: webform-required_preview-2460401-1.patch, failed testing.

danchadwick’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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

uno’s picture

In my case ( 7.x-4.x-dev ), if mandatory fields are empty, clicking preview button makes webform unusable, only labels are shown, no input option.

*EDIT*
Disregard this - had set .error in css to display:none.

arun ak’s picture

I am also facing one issue similar to this.

Suppose if I added a Page break component in webform, then preview page coming automatically. Even if I am not enabling Preview in form settings also preview page comming.

danchadwick’s picture

Re #11. Your situation is webform CORRECTLY handling an edge case. If the last page(s) of a webform are conditionally hidden, then clicking "NEXT" would unexpectedly submit the form. To avoid this, webform instead displays the preview page to prevent this inadvertent submission and give the user a chance to decide to actual submit.

Don't like this? Don't hide your last page.