Recurring date validation is wrongly triggered even if the relevant date field is not actionable on the page (e.g. with translations)

Created on 25 October 2024, about 2 months ago

Problem/Motivation

Following up from ๐Ÿ› Warning: Undefined array key "time_wrapper" Fixed , the following warning is emitted when the end date is in an invalid state.

Warning: Undefined array key "time_wrapper" in Drupal\smart_date_recur\Entity\SmartDateRule::validateRecurring() (line 945 of modules/contrib/smart_date/modules/smart_date_recur/src/Entity/SmartDateRule.php).

Warning: Trying to access array offset on value of type null in Drupal\smart_date_recur\Entity\SmartDateRule::validateRecurring() (line 945 of modules/contrib/smart_date/modules/smart_date_recur/src/Entity/SmartDateRule.php).

Similarly to ๐Ÿ› Start/End Date error messages Active , the warning message is also applied on the global element, rather than the specific end date.

The main crux of the matter is that under the same conditions as defined in ๐Ÿ› Smart Date Recurring doesn't work in non translatable field Needs review , the warning is also shown for translated content even when the specific date field is not visible to the user. I believe it should skip the validation for inaccessible fields.

Steps to reproduce

1. Create a recurring date with a start and end date of 25/10/2024 01:00 PM - 14/04/2025 04:00 PM.
2. Specify that it repeats weekly on Monday, and has an ends on date of 14/04/2025.
3. Attempt to save the content, it saves just fine.
4. Translate the piece of content, and attempting to save will trigger the warning. This is because the end date is actually 14/04/2025 12:00 AM which is smaller than the end date.

Proposed resolution

1. Fallback to using the title from the value element for the error message.
2. Apply the error message on the end date field.

Remaining tasks

Provide issue fork.

User interface changes

N/A

๐Ÿ› Bug report
Status

Active

Version

4.2

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024