Problem/Motivation

Following up from #3444046: Warning: Undefined array key "time_wrapper", 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 #3477741: Start/End Date error messages, the warning message is also applied on the global element, rather than the specific end date.

Steps to reproduce

1. Create a recurring date with a start and end date of 04/11/2024 01:00 PM - 04/11/2024 02:00 PM.
2. Specify that it repeats weekly on Monday, and has an ends on date of 28/10/2024.
3. The error is triggered.

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

Issue fork smart_date-3483466

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

codebymikey created an issue. See original summary.

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

abhishek_gupta1’s picture

Status: Active » Needs review

@codebymikey, I have fixed the issue and created MR. Please review it once

codebymikey’s picture

Assigned: Unassigned » codebymikey
Status: Needs review » Needs work

Hi @abhishek_gupta1, the MR partially addresses the issue, but currently has some coding standards issues as well as making changes to other unaffected parts of the code. The merge request title and commit messages also aren't the most helpful for reviewing, you should try to follow the Drupal commit message format as suggested in the Credit & committing section of the page.

I have a fix I'm working on locally that addresses the issue whilst also supporting translated content, so will probably force-push that into the issue fork instead (but since I can't change the merge request title, I might push mine into a separate branch instead). Thanks for attempting to fix the issue though.

codebymikey changed the visibility of the branch 3483466-recurring-date-validation to hidden.

codebymikey’s picture

Issue summary: View changes

The main crux of the matter is that under the same conditions as defined in #3194515: Smart Date Recurring doesn't work in non translatable field, 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.

The fix for that will be addressed in that issue so as not to conflate issues.

codebymikey’s picture

Title: Recurring date validation is wrongly triggered even if the relevant date field is not actionable on the page (e.g. with translations) » Recurring date validation targets undefined form elements
Assigned: codebymikey » Unassigned
Status: Needs work » Needs review
mandclu’s picture

mandclu’s picture

Status: Needs review » Fixed

Thanks for identifying this, and for the work to implement a fix. Merged in.

Status: Fixed » Closed (fixed)

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

codebymikey’s picture

It doesn't appear the MR has been merged in.