Problem/Motivation
This relates to webforms with a scheduled closing date, where the form is loaded (or a draft resumed) shortly before the cutoff point, but submitted after it.
Non-AJAX form: behaves as expected: on submission you receive a "Sorry…This form is closed to new submissions." message.
(Minor point, I'd argue form_open_message and form_close_message should be shown as errors (red) rather than success (green), but I'm struggling to find where that code actually is in the module.)
AJAX enabled form: if you load the form before the closing time but submit afterwards, the XHR produces an internal server error - specifically it throws the exception in core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php:67 about the AJAX callback being empty.
Having just done remote Xdebug on that, in the preceding code, $form_state->getTriggeringElement() returns null, and thus $callback is null.
(I appreciate that alone may not be very useful.)
Proposed resolution
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | Screen Shot 2019-06-12 at 10.49.31 PM.png | 162.1 KB | jrockowitz |
| #11 | 3025554-11.patch | 6.55 KB | jrockowitz |
| #10 | 3025554-10.patch | 3.87 KB | jrockowitz |
| #8 | 3025554-8.patch | 1.88 KB | jrockowitz |
| #4 | 3025554-4.patch | 3.62 KB | jrockowitz |
Comments
Comment #2
jrockowitz commentedWow, I initially thought I could not solve this problem but I think I figured out the solution.
The attached patch hides the submit buttons using
'#access': FALSEinstead of completely removing them. Please review the attached patch.Comment #4
jrockowitz commentedComment #5
jrockowitz commentedMy patch does not seem to be fixing this issue.
Below is the exact error message.
Comment #6
wturrell commentedYes, error unchanged with patch for me also.
Comment #7
jrockowitz commentedYep, I am going to have look at exactly what is throwing the error. I really afraid to think that the form's current state/token is lost when a webform is automatically closed.
Comment #8
jrockowitz commentedThe attached patch prevents the fatal error and instead displays an alert stating "Unable to complete the request. Please reload the current page."
Comment #9
jrockowitz commentedSo I have run into #2352009: Bubbling of elements' max-age to the page's headers and the page cache when testing this issue because the cached anonymous form is not being updated to display the closed message after the form is closed.
Comment #10
jrockowitz commentedThis patch begins to address the caching issue.
Comment #11
jrockowitz commentedThe attached patch displays the below confirm dialog and then reloads the page.
Comment #12
jrockowitz commentedManual test script
Comment #14
jrockowitz commented