When the Widget Inline entity form - Complex is used and no edits are made in the entities, they are not ordered by weight. This happens when using Layout builder and adding to it, custom blocks that have fields with this type of widget.

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

mmaldonado created an issue. See original summary.

mmaldonado’s picture

abarrio’s picture

Status: Active » Needs review

Changing to Needs review in order to launch tests

geek-merlin’s picture

Version: 8.x-1.0-rc6 » 8.x-1.x-dev

Thanks for spotting this!

I am surprised this did not pop up earlier.

When i look at the patch, i wonder it this can make use of existing code.

mmaldonado’s picture

Hello @geek-merlin,
Yes, there could be a code refactoring for the ordering of the weights.
Regards

joachim’s picture

Issue summary: View changes
Issue tags: +Needs issue summary update

Either I don't understand what this issue is about, or I'm not managing to reproduce it.

These were my steps:

1. Edit a host entity which has 2 entities in the IEF field
2. Drag to change the order of the nested entities
3. Save the host entity form.
4. Edited it again to see if the reordering had had an effect

It worked as expected -- my re-ordering changes had saved.

Could somebody expand on the issue summary and ideally add steps to reproduce please?

strykaizer’s picture

I had the same issue, patch fixed the problem.

In my case, I have

- Custom entity as entity reference on a block_content entity
- Widget inline entity form complex
- Layout builder available per node

Weights were not being updated, after patch from #2, issue was gone

Thanks!

joachim’s picture

@StryKaizer could you explain the precise steps to reproduce the problem please?

strykaizer’s picture

Sorry, for now I lack the time to test/document how to reproduce this on a vanilla environment.

Our project has following setup

- overrideable layout per node (layout builder)
- layout builder AT is enabled (not sure if necessary to reproduce)
- We have block_content entities, which have an entity_reference to custom coded entities. We place these block_content entities as a "custom block" using the layout builder.
- When editing a node's layout, form of the content_block entity is rendered with the complex IEF widget, in the front-end layoutbuilder, in a modal form.

When changing weights in that modal in the frontend, and saving, the weights are ignored without patch from #2

strykaizer’s picture

Issue summary: View changes
StatusFileSize
new800.78 KB

Attached is a screencapture which shows how it works WITH patch.
Without the patch, the order of "Boek een onderhoud" and "Carrosserie" was not changed.

What you see is a node, and we alter a specific "custom block" from a specific "section" in layout builder.

Hope this helps? ;)
Feel free to contact me on slack if you need more help (Strykaizer)

geek-merlin’s picture

Title: The order or weight is not updated without having edited some of the online entities, when the widget is used: Widget Inline entity form - Complex. » IEF complex widget: Re-ordering / weight sometimes not updated
r_h-l’s picture

This breaks rc9, due to Crypt no longer being loaded, and its replacement with a method. Attaching corrected patch

a3hill’s picture

Patch #12 worked for me with rc9.

geek-merlin’s picture

Issue tags: +Needs tests

Great. Can we have a test for this?
Load, change weight columns, save, assert?

geek-merlin’s picture

Status: Needs review » Needs work
nathandentzau’s picture

Patch #12 worked for me IEF RC9 and Drupal 9.2. Thanks for the patch!

rajab natshah’s picture

✅ Tested adding the 3136514-02.patch from patch from #12 to fix inline_entity_form-1.0-rc9 under Drupal 9.2.x

Thank you :)

artemboiko’s picture

+1, 3136514-02.patch patch fixed problem on Drupal 9.2.7

couloir007’s picture

This patch has been around a while, any sense of when it'll make it into the module?

rajab natshah’s picture

Tested #12 with Inline Entity Form 2.0.0-beta3

rajab natshah’s picture

Tested #12 with Inline Entity Form 2.0.0-beta6

rajab natshah’s picture

Assigned: mmaldonado » Unassigned

  • podarok committed 3b0b8ddc on 2.0.x authored by R_H-L
    Issue #3136514 by mmaldonado, R_H-L, StryKaizer, Rajab Natshah, geek-...
podarok’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs work » Fixed

#12 is in
tnx

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

geek-merlin’s picture

Version: 2.0.x-dev » 3.x-dev
Status: Closed (fixed) » Needs review
Related issues: +#3401656: Clean up problematic 2.x branch

Bulk reopen.

geek-merlin’s picture

Status: Needs review » Needs work

Needs an automated test.

dcam’s picture

This is a duplicate of #3033241: Cannot update the order weight using complex form widget. Both issues have patches with widely different solutions. We need to figure out which one to implement (if any). Both patches need tests. The less desirable solution's issue needs to be closed after granting credit to all contributors in the other issue.

dcam’s picture

After evaluating the two available solutions, my preference is to close this one. This patch adds more code to sort the references in the event no entity was changed. But that function already sorts the references toward the end. So this introduces a huge code and functionality duplication problem. What happens if or when sorting functionality needs to be updated or fixed? That's just asking for more bug reports.

Furthermore, the #3033241: Cannot update the order weight using complex form widget patch removes the code that causes the bug. This patch just works around it. Maybe the other patch isn't a complete solution yet, but I would rather start from that point than just add more code bloat to this module.

rajab natshah’s picture

Attached a static inline_entity_form--2024-12-27--3136514--mr-126.patch file, from the MR126 up to this point.
to be used with Composer Patches

rajab natshah’s picture

Attached a static inline_entity_form--2025-01-04--mr-126.patch file, from the MR126 up to this point.
to be used with Composer Patches