Commit fa9b51eb authored by yched's avatar yched

#114346 - fix error on empty noderef fields

parent 984bbd71
......@@ -109,10 +109,12 @@ function nodereference_field($op, &$node, $field, &$items, $teaser, $page) {
case 'validate':
$refs = _nodereference_potential_references($field, TRUE);
foreach ($items as $delta => $item) {
$error_field = isset($item['error_field']) ? $item['error_field'] : '';
unset($item['error_field']);
if (!in_array($item['nid'], array_keys($refs))) {
form_set_error($error_field, t('This post can\'t be referenced.'));
if (isset($item['nid'])) {
$error_field = isset($item['error_field']) ? $item['error_field'] : '';
unset($item['error_field']);
if (!in_array($item['nid'], array_keys($refs))) {
form_set_error($error_field, t('This post can\'t be referenced.'));
}
}
}
return;
......@@ -319,10 +321,10 @@ function nodereference_widget($op, &$node, $field, &$items) {
$nid = (!empty($nids)) ? array_shift(array_keys($nids)) : 0;
}
}
// Remove the widget's data representation so it isn't saved.
unset($items[$delta]['node_name']);
if (!empty($nid)) {
$items[$delta]['nid'] = $nid;
// Remove the widget's data representation so it isn't saved.
unset($items[$delta]['node_name']);
$items[$delta]['error_field'] = $field['field_name'].']['.$delta.'][node_name';
}
elseif ($delta > 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment