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.
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
| Comment | File | Size | Author |
|---|
Issue fork smart_date-3619470
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
Comment #2
gurkawal commentedHi
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.
Comment #4
codebymikey commented