tags:

views:

239

answers:

0

I am making nodes programmatically. One node field is a nid reference to a node of type Meet. I have set these attributes to a real node of type Meet. However, when I run this node object through node_validate(), I get an error:

Meet: this post can't be referenced.

Why does this happen? Here is the node object:

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
                )

        )

)

Also, I'm not really sure what's going on with the error reporting. This is my function to validate the nodes:

$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.'));
    }
}

I would expect that if any error were generated by node_validate(), the additional form_set_error() call would be fired. However, I get only one error, which is the one referenced above. Am I misunderstanding these functions?