Hi,

In a view for showing documents I've added a form for adding an item to the currently shown document. The form contains a node reference that points to the current node:

$form['field_node_referentie']['nids']['#default_value'][0] = arg(1);

This works without problems. As the user doesn't need to select a node reference manually in this case, I'd like to hide the node reference field. So I tried several variations of this:

$form['field_node_referentie']['#type'] = 'hidden';
$form['field_node_referentie']['nids']['#value'][0] = arg(1);

A title field can be hidden this way, so why not a node reference field? But in this case an error is displayed: "This post can't be referenced."

Apparently my experiments aren't accepted...

How can I hide the node reference field?

Comments

bestknight’s picture

I don't have the programming skills to do this but:

Can we unset the hiding of the node referenced field on clicking the submit button, before form processing for submission? Would this work? Can you come up with the code to try it?

bestknight’s picture

See http://drupal.org/node/250411 for the same issue

rdgouw’s picture

Issue solved. Please check:

http://drupal.org/node/250411#comment-830282

(Sorry for the double post)