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

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

peter törnstrand created an issue. See original summary.

peter törnstrand’s picture

And 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.

peter törnstrand’s picture

Issue summary: View changes
peter törnstrand’s picture

This was way more complicated that I thought. The trick with hiding repeating date instances with #access = FALSE works 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.

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

benstallings’s picture

Version: 4.1.6 » 4.2.x-dev
Status: Active » Needs review

Thank you for this, @peter törnstrand!

I updated this to work with 4.2 and made a merge request.

afi13’s picture

Status: Needs review » Reviewed & tested by the community

Works fine

mortona2k’s picture

Status: Reviewed & tested by the community » Needs work

I'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.

schillerm’s picture

Hi, 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.

nkind’s picture

Can 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.

nkind’s picture

Patch 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

nkind’s picture

nkind’s picture

Here's the corrected diff for the patch

nkind’s picture

Status: Needs work » Needs review
mortona2k’s picture

Status: Needs review » Needs work
StatusFileSize
new61.08 KB

@nkind - I don't see a remove button. Are you using the Multiple Fields Remove Button module?

Smart date single value delete button not showing

nkind’s picture

@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.

mortona2k’s picture

Yes that was D11.