Problem/Motivation

When adding ECK entity with entity-connect to another ECK entity we get the error shown below.

Undefined property: Entity::$id in entityconnect_eck_entityconnect_child_form_submit_alter() (line 115 of /code/sites/all/modules/entityconnect/modules/entityconnect_eck/entityconnect_eck.module).

This happen because code in entityconnect_eck.module line 115 tries to get the new entity id property before the entity was saved.
See image 3. ($form_state['values']['entity']->id;)

The bug is caused by incorrect order of submit handlers set on the form object by entity-connect module
see image 1 and image 2

The fix need to make sure submit handlers in entity-connect module are added in the correct order so we first save the entity, only after that we assign the entity to parent.

Steps to reproduce

1. Create ECK entity A and add field for adding another entity reference ECK entity B (unlimited)
2. Set entity-connect for this field.
3. Use entity connect to assign new entity B into entity A

Proposed resolution

The submit_handlers order is incorrect. The first handler need to be the one that save the ECK entity because only then the id of entity is assigned. The other two submit handlers need to be set after this one.

The current order of handles on $form is:

$form['actions']['submit']['#submit'][] = 'entityconnect_include_form';
$form['actions']['submit']['#submit'][] = 'entityconnect_child_form_submit';
$form['actions']['submit']['#submit'][] = 'eck__entity__form_submit';

Need to be

$form['actions']['submit']['#submit'][] = 'eck__entity__form_submit';
$form['actions']['submit']['#submit'][] = 'entityconnect_include_form';
$form['actions']['submit']['#submit'][] = 'entityconnect_child_form_submit';

Remaining tasks

User interface changes

API changes

Data model changes

Comments

rhizomenetworks created an issue. See original summary.

rhizomenetworks’s picture

StatusFileSize
new116.83 KB
new18.34 KB
rhizomenetworks’s picture

Issue summary: View changes
rhizomenetworks’s picture

astonvictor’s picture

Status: Active » Closed (outdated)

D7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.