Webform element: support Exceptions and Seasons

Created on 11 November 2024, about 2 months ago

Problem/Motivation

in v1.16, a 'ComplexWidget' was introduced, encapsulating Weeks, Seasons and Exceptions.
However, this is not supported in the Webform element.

Steps to reproduce

- Add a office_hours field to the webform
- Enable the Seasons and Exceptions toggles.
- Test the webform: only normal week is displayed.

Proposed resolution

In WebformOfficeHours.php, replace 'office_hours_default' with 'office_hours_exceptions'.

    // @todo Use 'office_hours_exceptions' ID to add Exceptions and Seasons.
    $widget = $this->getOfficeHoursPlugin('widget', 'office_hours_default', $this->getFieldDefinition());

However, after doing that, the following WSOD error appears:

The website encountered an unexpected error. Try again later.

Drupal\Core\Field\FieldException: Attempted to create an instance of field with name officehours on entity type webform_submission when the field storage does not exist. in Drupal\field\Entity\FieldConfig->getFieldStorageDefinition() (line 316 of core\modules\field\src\Entity\FieldConfig.php).
Drupal\Core\Field\FieldConfigBase->getSettings() (Line: 287)
Drupal\Core\Field\FieldConfigBase->postCreate(Object) (Line: 142)
Drupal\field\Entity\FieldConfig->postCreate(Object) (Line: 235)
Drupal\Core\Entity\EntityStorageBase->create(Array) (Line: 521)
Drupal\Core\Entity\EntityBase::create(Array) (Line: 166)
Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItemList->getFieldDefinition('office_hours_exceptions') (Line: 59)
Drupal\office_hours\Plugin\Field\FieldWidget\OfficeHoursComplexWeekWidget->formElement(Object, 0, Array, Array, Object) (Line: 155)
Drupal\office_hours\Plugin\WebformElement\WebformOfficeHours->prepare(Array, Object) (Line: 173)
Drupal\webform\Plugin\WebformElementManager->buildElement(Array, Array, Object) (Line: 2594)
Drupal\webform\WebformSubmissionForm->prepareElements(Array, Array, Object) (Line: 835)
Drupal\webform\WebformSubmissionForm->form(Array, Object) (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object) (Line: 648)
Drupal\webform\WebformSubmissionForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

1.0

Component

Integration

Created by

🇳🇱Netherlands johnv

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024