revision_id is submitted as empty if "Cancel" button was pressed

Created on 27 August 2025, 2 months ago

Problem/Motivation

inline_entity_form + layout_builder + entity_reference_revisions

Fields are revisionable, new revision is on.

So once you opening existing whatever (block in our case which is represented by entity_reference_revisions)
if you click any "update" button - all is OK.
But if you click "Cancel" results will go to upper conxtext entity_reference_revisions with ['target_revision_id'] === ''.
And this is because of modules/contrib/inline_entity_form/src/Element/InlineEntityForm.php::processEntityForm() having a lines

    // Handle revisioning if the entity supports it.
    if ($entity_type->isRevisionable() && $entity_form['#revision']) {
      $entity_form['#entity']->setNewRevision($entity_form['#revision']);

which enforce ['#entity']['revision_id'] to be erased at the begining of lifecycle where process where form is build.
Unlike "update" buttons "cancel" does not invoke

$inline_form_handler->save($entity_form['#entity']);

which populates empty revision_id with new value, so page gets broken.

We have tested this bug down to v1 of inline_entity_form till 2023 - it is present in all versions.

Steps to reproduce

Described above +

Proposed resolution

not to $entity_form['#entity']->setNewRevision($entity_form['#revision']); if triggering_element is 'cancel'.
Thanks Mindaugas Svirskas (AKA @mindaugas-svirskas β†’ AKA @msfranklydk β†’ ) for suggesting and testing this simple and working idea

Remaining tasks

none.

User interface changes

none.

API changes

none.

Data model changes

none.

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine mykola dolynskyi Poltava

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024