IEF Entity Reference association structure doesn't work with entityreference_field_validate()

Created on 20 November 2013, over 11 years ago
Updated 8 January 2025, about 2 months ago

If you use a debugger to watch entityreference_field_validate(...) function, you'll see that the IEF fields pass right through this section:


foreach ($items as $delta => $item) {
if (!entityreference_field_is_empty($item, $field) && $item['target_id'] !== NULL) {
$ids[$item['target_id']] = $delta;
}
}

There is no $item['target_id'], so the $valid_ids is never checked.

I'm not sure if this is a feature or a bug. I ran into it when using EFQ Views as my autocomplete results which does set a a target_id, but it's directly on $item, $item is not an array like $item['target_id'] = 1234, but $item = 1234. That was causing invalid referenced entity errors.

IEF will create an $item like this:

$item = array(
'entities' => array(
array(
'delta' => 0,
'actions' => array(...)
)
)
);

The entityreference_field_validate(...) function expects $item to have a 'target_id' key for it to actually validate the $ids.

πŸ› Bug report
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bendiy

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.

  • πŸ‡ΊπŸ‡ΈUnited States dcam

    Since Drupal 7 is now end-of-life I am closing some old issues for the 7.x branch of this module. If this issue is still relevant for the 3.x branch of the module, then feel free to reopen it.

Production build 0.71.5 2024