Problem/Motivation

The Multiple Fields Remove button module does not work for Smart Date field with Recurrence enabled.

Steps to reproduce

  1. Install the Smart Date module and Smart Date Recurring module
  2. Create a Smart Date range field with Recurring option enabled and Allowed number of values as Unlimited in a Content type
  3. Install the Multiple fields remove button module
  4. Create a node of prior mentioned content type which has a Smart Date range field with multiple values
  5. Save the content, edit it and try removing any of the recurrence values from within the Smart Date field. The field does not get deleted.

Proposed resolution

The multiple fields remove button's submit handler fetches the delta of the delete button pressed and tries to loop sequentially over available recurrences to push them back by one place over the deleted element. However, for a Smart Date field with recurrence enabled the delta value of each field of recurrence element does not appear to be sequential. Also the items_count value in the widget's field_state provides a value different from the total count of items. Both of these negate the shifting logic responsible for the delete functionality to work. However for a Smart Date field without recurrence enabled the delta values are in sequence and work as intended. Requesting suggestions on how to get the Smart Date with Recurrence enabled to work with multiple fields remove button module.

Comments

optimusprime619 created an issue. See original summary.

jonraedeke’s picture

I'm having the same issue.

jglynn’s picture

Seems to be a pretty major bug if you can't remove a recurring date?

jonraedeke’s picture

Category: Support request » Bug report

I agree. There appears to be no alternative way to remove dates from a smartdate widget when multiple dates are allowed.

mandclu’s picture

Version: 3.4.3 » 3.5.0-rc1

I had reproduced this error previously, but when I tried it again just now with the most recent version of Smart Date (3.5.0-rc1) it seemed to work as intended. Please test again with the version and let me know if you're still seeing a problem.

Also worth noting that even without Multiple Fields Remove Button it isn't accurate to say "you can't remove a recurring date". It is also possible to tab through the values of the entry you want to delete and hit the backspace key through all of them. When saved it will delete that entry, although if the end date was hidden it may throw a validation error, in which case it will show the end date, at which point you can remove the values there too. I admin this isn't anywhere near as elegant a solution as using Multiple Fields Remove Button, but it is available as a workaround.

jonraedeke’s picture

Category: Bug report » Feature request

Sorry, I must not have deleted all the fields when trying to remove a recurring date without using the Multiple Fields Remove Button. Thanks for the trick of tabbing through the fields to clear them.

Unfortunately, I'm still experiencing difficulty using the Multiple Fields Remove Button with the latest release (3.5.0-rc1).

Setup

  • A "smart date range" field set to unlimited cardinality
  • Allow recurring date values

Scenario #1

  1. Enter one date with a recurring rule
  2. Save node
  3. Edit node and click the remove button for the date instance
  4. I would expect this to clear the values. It appears to only clear after the remove button is clicked the number of times of the repeat instances plus one.

Scenario #2

  1. Enter a date with no recurring rule
  2. Enter another date with a recurring rule
  3. Save node
  4. Edit node and click the remove button for the first date instance
  5. I would expect this to clear the first non-recurring instance. Instead it actually appears to duplicate the second recurring instance.
  6. If you continue clicking the remove button for the first instance the number of times matching the number of recurring instances, it clears.

Scenario #3

  1. Enter a date with a recurring rule set to 3 repeats
  2. Enter another date a recurring rule set to 5 repeats
  3. Save node
  4. Edit node and click the remove button for the first date instance
  5. I would expect this to clear the first instance. Instead it doesn't appear do anything on the first click.
  6. If you continue clicking the remove button for the first instance the number of times matching the number of repeats of the second instance , it actually removes the second instance.
mandclu’s picture

Status: Active » Needs review
StatusFileSize
new1.58 KB

It took a fair bit of testing to figure out where the change is needed, but as is often the case in Drupal the eventual fix seems to be incredibly simple. Please test and validate that this addresses the issues you've observed.

  • mandclu committed 5287772 on 3.5.x
    Issue #3245852 by mandclu: Multiple fields remove button fails for Smart...
mandclu’s picture

Status: Needs review » Fixed

I wanted to make some other changes that might conflict with the changes here, so merging in. If you find additional issues, feel free to reopen.

jonraedeke’s picture

Status: Fixed » Active

Sorry for the delay and thank you for working on this. I wanted to make sure my issue was not due to other code on my site. I tested the dev version on a fresh Drupal install and, unfortunately, still have the same issues for all 3 scenarios.

Drupal 9.3.2
Smart Date dev-3.5.x e7a731c
Multiple Fields Remove Button 8.x-1.0-alpha13

mark_fullmer’s picture

I can corroborate that this problem still exists on the 3.5.x branch as of 2022-01-31, which includes the commit above.

The scenario I encounter this issue in is:

1. Enter a date with a recurring rule set to a daily repeat, with one or more days selected.
2. Enter another date with a recurring rule set to a daily repeat, with one or more days selected.
3. Attempt to remove either using the Multiple Fields Remove Button. Neither instance can be removed.

For an immediate workaround, I can set "Repeats" to "Never" on the event instance I want to remove, and clear out the date values, then save the node. Upon reloading of the node form, the event instance is removed.

jrockowitz’s picture

I was able to use the remove recurring Smart date using

drupal 9.4.5
multiple_fields_remove_button 8.x-1.0-alpha13
smart_date 3.7.0-beta1

optimusprime619’s picture

@jrockowitz Thank you for the update. I tested the same with Drupal 9.4.8 and same versions of the contributed modules you mentioned. It looks like the issue does not exist any more.

jeffschuler’s picture

I am unfortunately still experiencing this issue, just as described in #11 by @mark_fullmer.

Reproduced with:

  • drupal 9.4.8
  • smart_date 3.6.1, 3.7.0-beta1, and 3.7.0-beta2 (tried all three)
  • multiple_fields_remove_button 8.x-1.0-alpha13

No JS errors nor Drupal log messages.

In addition to @mark_fullmer's workaround, I note that this also works:

  1. Change "Repeats" to "Never" (but leave dates intact)
  2. Save node and re-edit
  3. NOW, the multiple_fields_remove_button functionality works on that date instance.
tisteegz’s picture

Experiencing this issue also.

Drupal: 9.5.9
Smart date: 4.0.2
Multiple Fields Remove Button: 8.x-2.2

When I go to remove a date with a recurring date rule it just says 'please wait...' and then nothing happens. No error, just doesn't remove it.

intersarsi’s picture

I recently installed the module with this configuration and it works for me:

Drupal 10.0.9
Smart Date 4.0.2
Multiple Fields Remove Button 8.x-2.2

flitt1’s picture

StatusFileSize
new510 bytes

UPDATE:
The patch I uploaded does not work, do not use it. I can't figure out how to remove the patch file from this issue, but after further testing I realized that although it looks like the dates are being removed, an extra instance is added below the other dates. It seems that the workaround of switching to 'never' prior to clicking the remove button is the only thing that works to remove multiple dates at the moment.

--------------------------------------
This issue is reproducible in Smart Date 4.0.3, but I noticed that the patch provided by @mandclu partially applies and the partial application fixes the issue. Here is a new version of the patch with the change to SmartDateWidgetBase.php that was in the original patch but was not changed in the source code.

Note that this issue is also reproducible in 4.1.0-rc6. I tried updating in case it would resolve the issue but it didn't, and the patch is not compatible with that version. The only resolution that has worked for me has been to use version 4.0.3 and apply the change to SmartDateWidgetBase.php that was in the original patch.

tobiasb’s picture

nkind’s picture

Issue persists for me with:

Drupal: 10.4.1
Smart Date: 4.2.3
Multiple Fields Remove Button: 8.x-2.2

freelock’s picture

Just curious -- for people still affected by this, do you perhaps have ECA Form module enabled? I'm wondering if it's related to this: #3469697: ECA Form breaks complex IEF widget

ll66382’s picture

I was just testing and see it on a core field--

To repro:
1. Disable smart_date, multiple_fields_remove_button.
2. Create two new fields:
2.a. Date and time (Date, multiple)
2.b. Date and time (Timestamp, multiple)

Author new node, add multiple field values, then save it.
Edit the node and try removing values.

Result:
1. Can remove all Date field values
2. Cannot remove all Timestamp field values

I could be wrong but, looks like a core issue. Maybe multiple_fields_remove_button (if drupal 9). I'll look more.

Versions: Drupal version : 10.4.5

lindsay.wils’s picture

Just confirming that this issue is still in place

Drupal: 11.1.8
smart_date: 4.2
multiple_fields_remove_butto: 2.3

The workaround of setting recurring to none only works if the item is last in the list, otherwise a duplicate item is added to the bottom.

mortona2k’s picture

The patch in this issue might avoid the need for this extra module.

mortona2k’s picture

Version: 3.5.0-rc1 » 4.2.x-dev

Bumping to the latest branch, where the fix should be applied first.

I'm seeing very similar behavior when using this module vs the patch for the native remove button in the link above.

I encourage directing effort toward the other ticket, since a native remove button means we don't need an extra module.

mortona2k’s picture

This issue recommends DateTime Reset as a way to clear out the values, which should remove the extra items on save as per #5.

mandclu’s picture

Status: Active » Closed (duplicate)

I agree with the assessment of @mortona2k that the approach in #3495251: Incorporate the single value delete button from Drupal core 10.2 is preferable because it avoids needing another module. The work there has been merged in, so closing this as duplicate. Thanks for everyone's contribution to the discussion here.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.