Since Drupal core 10.2 a delete button that makes it possible to delete a single value from a multiple value field is available, see #1038316: Allow for deletion of a single value of a multiple value field.
This button is however not present in the widget for Smart date due to override in SmartDateWidgetBase::formMultipleElements().
The attached patch fixes this.
I'm not sure how to handle the fact that this functionality is only available on core >=10.2.
Issue fork smart_date-3495251
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
peter törnstrand commentedAnd here is the patch. This is done against version 4.1.6.I was a bit quick there .... this patch does not work. Working on a new one.
Comment #3
peter törnstrand commentedComment #4
peter törnstrand commentedThis was way more complicated that I thought. The trick with hiding repeating date instances with
#access = FALSEworks just fine for the widget display but not when it comes to deleting values.With a variant of the patch above I got it working so that if you have a repeating date with four instances you can click the Delete button four times to delete the complete "set".
Not very good.
Comment #7
benstallings commentedThank you for this, @peter törnstrand!
I updated this to work with 4.2 and made a merge request.
Comment #8
afi13 commentedWorks fine
Comment #9
mortona2k commentedI'm hitting an issue with this patch that seems similar to comments in linked issue for the Multiple Fields Remove Button module.
When the values are recurring, the remove button doesn't work. I see the form refresh, but comes back with the same values.
Comment #10
schillerm commentedHi, I just tested !MR173 and it worked ok for me (on a Drupal 11.2.3 site). I was able to delete/remove dates from a multi value smartdate field. Values remain after a refresh. The drush command also works. Phpunit tests pass. So +1 for RTBC from me.
Comment #11
nkind commentedCan confirm with #9 the current MR doesn't work with recurring dates.
Workaround being if you set the recurrence to never, then save, then it seems you can remove it.
Comment #12
nkind commentedPatch for a potential fix: Clicking "Remove" on a recurring instance now marks its rrule as deleted in field state and the deletion persists through form rebuilds via AJAX which seemed to be one of the primary problems.
edit: doesn't seem to apply, working on a refactor
Comment #13
nkind commentedComment #14
nkind commentedHere's the corrected diff for the patch
Comment #15
nkind commentedComment #16
mortona2k commented@nkind - I don't see a remove button. Are you using the Multiple Fields Remove Button module?
Comment #17
nkind commented@mortona2k I'm not using the Multiple Fields Remove button just the patch I supplied. Are you on Drupal 11? I haven't validated it on there yet.
Comment #18
mortona2k commentedYes that was D11.