Problem/Motivation & Steps To Reproduce
If a webform is in Open form status, and along the way you want to schedule a Close date...
on the Settings->Form screen, under "Form general settings", if you then enter a Close date & time, then click Save at the bottom of the page, then go back and view the Close date you just entered, it is empty...

I found this is due to these lines in src/Entity/Webform.php:
// Clear open and close if status is not scheduled.
if ($this->status !== WebformInterface::STATUS_SCHEDULED) {
$this->open = NULL;
$this->close = NULL;
}
This is present on both 6.3.x-dev and 6.2.9 branches.
Whereas evidently if the form status is not Scheduled, and anything is entered into the Open or Close date&time fields, then those fields will just be wiped empty. The user likely will not catch that their Close date&time was wiped; no message is displayed to inform the user that they entered data into a field that was not being honored.
The only way I see to schedule an Open form to close, is to change the Form status to Scheduled, then put some past date into the Open date&time field, and then set the Close date&time.
Proposed resolution
Perhaps at least the Open and Close date&time fields should be hidden if the form status is not Scheduled?
| Comment | File | Size | Author |
|---|---|---|---|
| open_close.png | 20.45 KB | fizcs3 |
Issue fork webform-3510721
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
cilefen commentedYes, it's just broken. I posted a naive merge here. Test it out.
The form element I fixed has
@see \Drupal\webform\Plugin\Field\FieldWidget\WebformEntityReferenceAutocompleteWidget::formElementbut that is gone or has moved, and I don't know the relevance.Comment #5
fizcs3 commentedNice, thank you @cilefen -- that is a very small and helpful code tweak.
Tested to find that it successfully makes Open/Close date form fields only appear when Scheduled form status is chosen.
Also applies cleanly to webform 6.2.9 for those of us still on it.
Moving to RTBC status.
Comment #7
annie.tao commentedMade the same change to /Plugin/Field/FieldWidget/WebformEntityReferenceWidgetTrait::formElement since I was seeing the issue on Webform Reference fields as well.
Comment #9
jrockowitz commentedThe tweak looks fine to me, and enough people have reviewed this
Comment #12
jrockowitz commented