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.
Comment | File | Size | Author |
---|---|---|---|
#1 | entity-selection.png | 13.36 KB | bendiy |
Comments
Comment #1
bendiy CreditAttribution: bendiy commentedComment #2
bojanz CreditAttribution: bojanz commentedWe have a bugfix for a similar issue in #1659586: Support Taxonomy term reference fields, basically an #element_validate callback that sets the id to NULL.
We probably need to make that fix work for all field types, and commit it.