Problem/Motivation
When adding a new entity it displays an incorrect 'published' status despite it being a new entity. The 'status' is TRUE by default which causes confusion when viewing the references. Once the nodes are saved, the new node will correctly display its status.
After creating a new node;

After saving the parent node;

Steps to reproduce
* Add an new entity to an existing node.
* Note the 'status' of the new entity is TRUE - leading to a 'published' status appearing for nodes.
* Note that the entity is not available elsewhere in the system - it is new
* After saving the parent the new entity will have a status of FALSE until it is published.
Proposed resolution
Patch incoming. Update status to FALSE when entity is new.
Remaining tasks
Review and decide if my patch is the correct approach.
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | Screenshot from 2025-10-16 10-20-32.png | 22.83 KB | santanu mondal |
| #2 | New-entities-have-a-true-status-3448173-2.patch | 638 bytes | cb |
| Screenshot 2024-05-20 at 12.31.56 PM.jpg | 51.16 KB | cb | |
| Screenshot 2024-05-20 at 12.31.37 PM.jpg | 42.89 KB | cb |
Issue fork inline_entity_form-3448173
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
Comment #2
cbPatch attached.
Comment #3
santanu mondal commentedComment #5
santanu mondal commentedI have fixed that issue when the node will create from inline entity then it will be by default unpublish and when the parent node save then the inline entity will be published.
Comment #6
santanu mondal commentedComment #9
benstallings commentedClaude Code says:
Issues
1. Undefined variable — InlineEntityForm.php:188
$entity is never defined in submitEntityForm(). The local $entity in buildEntityForm() (line 123) does not carry over — different static method. Under PHP 8 this throws Undefined variable. Should read $entity_form['#entity'] instead (matching the line above).
2. Missing use statements — fatal on load
inline_entity_form_entity_presave() takes EntityInterface and uses ContentEntityInterface, but neither is imported at the top of inline_entity_form.module. As written, the module will fatal on the first entity save of any kind once enabled. This is not theoretical — it'll brick the site.
3. Hook scope is catastrophic — inline_entity_form.module:492
inline_entity_form_entity_presave() runs on every node save, regardless of whether IEF was involved, then iterates every entity_reference field and force-publishes every referenced entity with a status key. Problems:
- Clobbers intentional state. Saving any node with a Media/Taxonomy/Paragraph reference will re-publish those children even if the editor deliberately unpublished them.
- Recursive $child->save() inside presave. Nested references with status keys will fire more presaves. Circular references = infinite loop.
- Performance. Load + save every referenced entity on every node save, forever.
- Ignores the ief_new marker the patch itself sets at line 126 — so the restriction to "only IEF-created entities" simply isn't there.
- Hardcoded to 'node'. IEF handles paragraphs, media, terms, commerce line items; restricting the hook to nodes is incoherent with the module's purpose.
4. ief_new dynamic property is lost across save boundary — line 126
$entity->ief_new = TRUE; sets a runtime-only dynamic property. It doesn't persist through load/save cycles, so any later code trying to read it back would find nothing.
5. Leftover debug logger — line 514
\Drupal::logger('inline_entity_debug')->notice('Published child entity: @id', …);Debug scaffolding. The channel name inline_entity_debug isn't even a real channel used by this module. Must be removed.
6. Hardcoded 'status' — line 189
Inconsistent with the rest of the patch, which correctly uses $child->getEntityType()->getKey('status').
7. Docblock / style
- /** This will publish the content that is create by inline entity form. */ — should be Implements hook_entity_presave().; typo ("create" → "created"); extra blank line at line 190; no braces around single-statement blocks elsewhere is fine but here the if block has awkward spacing.
8. Nullable-parameter changes are fine
The EntityInterface $entity = NULL → ?EntityInterface $entity = NULL and the Node $node = NULL → ?Node $node = NULL updates align with PHP 8.4 deprecation and are correct. These two small changes would be worth keeping; split them into their own commit.
Recommendation
Reject this patch and ask for a rewrite. It won't even load. Even if the missing use statements were fixed and the undefined $entity bug resolved, the hook_entity_presave approach is fundamentally wrong — it would force-publish every referenced entity on every node save, site-wide.
The real fix for #3448173 (new IEF entities not respecting the publish/unpublish toggle) should live inside IEF's own save path — most likely in WidgetSubmit::doSubmit() at src/WidgetSubmit.php:50-65, where it already saves the in-progress entities. The entity being saved there already carries whatever status value the user set on the inline form; if the bug is that IEF is losing/overriding that value, the fix is to trace where it's being overridden, not to globally republish via presave.
Comment #10
benstallings commentedComment #11
benstallings commented