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...

open close

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?

CommentFileSizeAuthor
open_close.png20.45 KBfizcs3

Issue fork webform-3510721

Command icon 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

fizcs3 created an issue. See original summary.

cilefen made their first commit to this issue’s fork.

cilefen’s picture

Status: Active » Needs review

Yes, 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::formElement but that is gone or has moved, and I don't know the relevance.

fizcs3’s picture

Status: Needs review » Reviewed & tested by the community

Nice, 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.

annie.tao made their first commit to this issue’s fork.

annie.tao’s picture

Status: Reviewed & tested by the community » Needs review

Made the same change to /Plugin/Field/FieldWidget/WebformEntityReferenceWidgetTrait::formElement since I was seeing the issue on Webform Reference fields as well.

jrockowitz made their first commit to this issue’s fork.

jrockowitz’s picture

The tweak looks fine to me, and enough people have reviewed this

  • jrockowitz committed da87397a on 6.3.x authored by cilefen
    Issue #3510721 by cilefen, annie.tao, fizcs3: Scheduling an Open webform...

  • jrockowitz committed da87397a on 6.x authored by cilefen
    Issue #3510721 by cilefen, annie.tao, fizcs3: Scheduling an Open webform...
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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