Problem/Motivation

Following on from the #3495251: Incorporate the single value delete button from Drupal core 10.2, the add more button has a '#limit_validation_errors' set, which limits validations to that single date field.

However when all dates are fully removed, you're unable to add a new date.

This is because the form now has a "This value should not be null." validation error, so doesn't allow it to be added back in.

Steps to reproduce

1. Have a required recurring date field saved.
2. Remove all the date field values.
3. Attempt to add the date field back.

Proposed resolution

Set the '#limit_validation_errors' to an empty array just like core does.

See #3076054: Existing field items should not be validated when adding another item in widget for unlimited cardinality field

Remaining tasks

Provide MR.

User interface changes

You may now add remove/add required Smart Date fields as necessary.

API changes

N/A

Data model changes

N/A

CommentFileSizeAuthor
#2 3619470-add-another-item-fix.patch733 bytesgurkawal

Issue fork smart_date-3619470

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.

gurkawal’s picture

StatusFileSize
new733 bytes

Hi

I reproduced the issue on drupal11.4 and prepared a patch.

The problem was caused by the Add another item button limiting validation to the Smart Date field only. Because of this, other form validation errors were not processed correctly when adding another item.

The patch changes #limit_validation_errors to an empty array:

'#limit_validation_errors' => [],

This allows the add-more action to run without triggering unrelated form validation while still adding the new Smart Date item correctly.

I tested the fix locally and confirmed that the issue is resolved.

Patch attached for review and testing.

codebymikey’s picture

Issue summary: View changes
Status: Active » Needs review