Closed (fixed)
Project:
Entity reference
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Sep 2012 at 23:25 UTC
Updated:
6 Feb 2018 at 06:53 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
richard.thomas commentedHere's a quick patch to move it.
Comment #2
richard.thomas commentedComment #4
richard.thomas commentedLet's try that again (one day I'll get the hang of this).
Comment #5
amitaibu> In my case I want to force selection of an entity for this particular field
You can already do this by implementing your logic in
EntityReference_BehaviorHandler::insert()orEntityReference_BehaviorHandler::update()Please re-open if you think differently.
Comment #6
richard.thomas commentedI could use other hooks (although none would be as neat), but my understanding is the behavior method validate() is supposed to be emulating hook_field_validate() for a specific entityreference field, so why wouldn't we call it in the same situations that hook_field_validate() is called? Is it an issue with changing the code path that behavior plugins may be relying on?
Comment #7
damien tournoud commentedSounds reasonable. I merged the attached patch in 7.x-1.x.
Comment #9
GeorgeJr commentedI'm getting "The referenced entity (node: 17029) is invalid." error since the id of the form being reset is included on the list of id's. To get rid of the error I check the node status before getting the id's.
foreach ($items as $delta => $item) {
$target_id = $item['target_id'];
if($target_id != ""){
$query = "SELECT `status`
FROM node
WHERE node.nid = $target_id";
$queryStatus = db_query($query)->fetchAll();
}
if (!entityreference_field_is_empty($item, $field) && $item['target_id'] !== NULL && $queryStatus['status'] == 1) {
$ids[$item['target_id']] = $delta;
}
}
Is it safe to place this query just to exclude the id of the reset forms?