我以编程方式制作节点。一个节点字段是对nid
类型节点的Meet
引用。我已将这些属性设置为Meet类型的实际节点。但是,当我通过node_validate()
运行此节点对象时,出现错误:
见面:此帖子无法引用。
为什么会这样?这是节点对象:
stdClass Object
(
[type] => bout
[name] => Gary Oak
[promote] =>
[comment] => 2
[revision] =>
[format] => 0
[status] => 0
[title] => the title 4
[uid] => 4
[field_touches_scored] => Array
(
[0] => Array
(
[value] => 4
)
)
[field_touches_received] => Array
(
[0] => Array
(
[value] => 5
)
)
[field_meet] => Array
(
[0] => Array
(
[nid] => 2583
)
)
[field_round] => Array
(
[0] => Array
(
[value] => 1
)
)
[field_legacy_bout] => Array
(
[0] => Array
(
[value] => 0
)
)
[field_weapon] => Array
(
[0] => Array
(
[value] => saber
)
)
)
另外,我不确定错误报告是怎么回事。这是我验证节点的功能:
$nodes_to_save = construct_nodes();
foreach ($nodes_to_save as $node) {
node_validate($node, $form);
if ($errors = form_get_errors()) {
form_set_error('', t('Validation error. No nodes saved.'));
}
}
我希望如果node_validate()
生成任何错误,则会触发额外的form_set_error()
调用。但是,我只得到一个错误,这是上面提到的错误。我误解了这些功能吗?