Problem/Motivation

It's possible to save an event series with the following options:
- Registration Type = Individual Event Registration
- Registration Dates = Scheduled Registration
- Registration Opens and/or Registration Closes = Custom schedule
- the related "amount" field -- either instance_schedule_open_amount or instance_schedule_close_amount = 0 or empty

Doing this causes problems in RegistrationCreationService::registrationOpeningClosingTime where lines like $reg_start->modify($open_time_modifier); try to modify a DateTime object with an empty value.

DateMalformedStringException: DateTime::modify(): Failed to parse time string () at position 0 ( ): Empty string in DateTime->modify() (line 366 of /var/www/html/web/core/lib/Drupal/Component/Datetime/DateTimePlus.php).

Steps to reproduce

Create an event with the options above, making sure that instance_schedule_open_amount or instance_schedule_close_amount is empty when clicking on the event Save button. Notice that the event will save. The empty values are converted into zero values. If any content is viewed that requires RegistrationCreationService::registrationOpeningClosingTime, the DateMalformedStringException will be triggered. For example, viewing the event instance will trigger RegistrationCreationService::registrationIsOpen, which calls RegistrationCreationService::registrationOpeningClosingTime

Proposed resolution

Ensure the event creation form checks for empty or zero values in these fields and returns form errors in those cases. Change the #min value for each number input to 1 instead of 0. Possibly add more checks in RegistrationCreationService::registrationOpeningClosingTime to triple-check that these fields have a value.

Example of form errors to be added

CommentFileSizeAuthor
Edit-default-08-25-2025_09_59_PM.jpg65.38 KBchrisla
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

chrisla created an issue. See original summary.

chrisla’s picture

MR adds validation for the event instance registration custom schedule fields and changes #min values to 1 (and removes one that doesn't need to exist).

Let me know if there is any feedback and if adding more checks to RegistrationCreationService::registrationOpeningClosingTime seems necessary.

chrisla’s picture

Status: Active » Needs review
chrisla’s picture

Just wanted to check if anyone has had a moment to review this

chrisla’s picture

Version: 2.0.3 » 2.0.x-dev

Requesting review and merge