Compatibility with multiple_fields_remove_button

Created on 21 April 2020, about 4 years ago
Updated 13 January 2024, 6 months ago

There's a longstanding request β†’ to allow deleting items in the simple widget. However, this is really an issue with Drupal fields themselves, not inline_entity_form. It's also an issue which multiple_fields_remove_button β†’ almost solves.

I found that when using multiple_fields_remove_button the last item in the inline_entity_form simple widget was always deleted in addition to the selected item. After much debugging this seems to be because the simple widget's extractFormValues() method overwrites weights of 0 under some circumstances, causing the last item with a weight of 0 to be overwritten by multiple_fields_remove_button's empty item also with a weight of 0. This might also have other side-effects for other modules which manipulate items/item order like multiple_fields_remove_button.

It's pretty simple to fix this in inline_entity_form - just a matter of deciding a fallback weight more dynamically. I'll attach a patch shortly.

✨ Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada Dylan Donkersgoed London, Ontario

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany SteffenR Germany

    Attached the re-rolled patch from #2 against latest dev version of inline_entity_form.

  • πŸ‡ΊπŸ‡ΈUnited States josephcheek Salt Lake City, UT

    Hello, #13 doesn't apply on the latest 2.0.0-rc5 due to (I think) the merge of https://www.drupal.org/project/inline_entity_form/issues/3097411 πŸ› Entity form simple weight duplicates Needs review , but I am not clear whether this patch is still necessary now that 3097411 is fixing the weight problem on its own. I am using multiple_fields_remove_button and have found that I cannot remove the entity reference when there is only one entity remaining in my multiple fields. So, it used to be that the last one was always removed, and now it can never be removed?

  • Status changed to Closed: outdated 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States dcam

    Drupal 10.2 added the Remove button to multiple-valued fields. See πŸ“Œ Allow for deletion of a single value of a multiple value field Fixed . I tested the button and it worked well for me.

Production build 0.69.0 2024