Closed (fixed)
Project:
Node Reference Create
Version:
6.x-1.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Jan 2011 at 21:03 UTC
Updated:
3 Jan 2014 at 02:41 UTC
Jump to comment: Most recent
Comments
Comment #1
koffieschaap commenteda fix would be something like this:
$reference = node_reference_potential_references($field, $options);
if ($reference) {
// @todo The best thing would be to present the user with an
// additional form, allowing the user to choose between valid
// candidates with the same title. ATM, we pick the first
// matching candidate...
$nid = key($reference);
}
else {
+ if(strlen(trim($value)) > 0){
$newnode = NULL;
if (is_array($field['settings']['referenceable_types'])) {
foreach (array_filter($field['settings']['referenceable_types']) as $related_type) {
$newnode->type = $related_type;
}
}
global $user;
$newnode->uid = $user->uid;
$newnode->title = $value;
$newnode->language = $element['#language'];
if (module_exists('comment')) {
$newnode->comment = variable_get("comment_$newnode->type", COMMENT_NODE_OPEN);
}
node_save($newnode);
$nid = $newnode->nid;
+ } else {
+ form_error($element, t('%name: title is empty. Please check your input.', array('%name' => $instance['label'])));
+ }
}
Comment #2
jackbravo commentedYes it is a bug. Corrected in dev.
Comment #3
jackbravo commentedThanks koffieschaap for the patch.