Problem/Motivation
The Multiple Fields Remove button module does not work for Smart Date field with Recurrence enabled.
Steps to reproduce
- Install the Smart Date module and Smart Date Recurring module
- Create a Smart Date range field with Recurring option enabled and Allowed number of values as Unlimited in a Content type
- Install the Multiple fields remove button module
- Create a node of prior mentioned content type which has a Smart Date range field with multiple values
- 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.
| Comment | File | Size | Author |
|---|
Comments
Comment #2
jonraedeke commentedI'm having the same issue.
Comment #3
jglynn commentedSeems to be a pretty major bug if you can't remove a recurring date?
Comment #4
jonraedeke commentedI agree. There appears to be no alternative way to remove dates from a smartdate widget when multiple dates are allowed.
Comment #5
mandclu commentedI 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.
Comment #6
jonraedeke commentedSorry, 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
Scenario #1
Scenario #2
Scenario #3
Comment #7
mandclu commentedIt 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.
Comment #9
mandclu commentedI 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.
Comment #10
jonraedeke commentedSorry 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
Comment #11
mark_fullmerI 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.
Comment #12
jrockowitz commentedI 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
Comment #13
optimusprime619 commented@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.
Comment #14
jeffschulerI am unfortunately still experiencing this issue, just as described in #11 by @mark_fullmer.
Reproduced with:
No JS errors nor Drupal log messages.
In addition to @mark_fullmer's workaround, I note that this also works:
Comment #15
tisteegz commentedExperiencing 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.
Comment #16
intersarsi commentedI 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
Comment #17
flitt1 commentedUPDATE:
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.
Comment #18
tobiasbComment #19
nkind commentedIssue persists for me with:
Drupal: 10.4.1
Smart Date: 4.2.3
Multiple Fields Remove Button: 8.x-2.2
Comment #20
freelockJust 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
Comment #21
ll66382 commentedI 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
Comment #22
lindsay.wils commentedJust 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.
Comment #23
mortona2k commentedThe patch in this issue might avoid the need for this extra module.
Comment #24
mortona2k commentedBumping 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.
Comment #25
mortona2k commentedThis issue recommends DateTime Reset as a way to clear out the values, which should remove the extra items on save as per #5.
Comment #26
mandclu commentedI 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.