When space is put in the field and submitted, a node is created with space as title but not clickable on the content page(http://www.example.com/admin/content/node)
I assume this as a bug. correct me if I am wrong.

Comments

koffieschaap’s picture

a 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'])));
+ }
}

jackbravo’s picture

Status: Active » Fixed

Yes it is a bug. Corrected in dev.

jackbravo’s picture

Thanks koffieschaap for the patch.

Status: Fixed » Closed (fixed)
Issue tags: -title, -nodereference, -create, -blank

Automatically closed -- issue fixed for 2 weeks with no activity.