Set the value of a hidden field in form block Using the code below in a block, I am displaying a form in a block on all pages for a content type called Goals. I want to use this block / form to update progress on the goal to a content type called Goal Progress, and connect the two through a key called goal_id - the nid of the Goal.

The challenge that I am having is setting the value for the goal_id field (Goal Progress content type). I suspect I need to use $form_state['values']['field_goal_id']['und']['0']['value'] = 'value'; to declare the value, but I can't figure out where that should be placed.

Been looking for a solution for a couple of hours now, so any suggestions are greatly appreciated.

&lt;?php 
  $node = menu_get_object();

  if (isset($node-&gt;nid)) {
    $nid = $node-&gt;nid;
  }

  module_load_include('inc', 'node', 'node.pages');
  $node_form = node_add('goal_progress');
  print drupal_render($node_form);
?&gt;
OK, I have found a working solution. I added $form['field_goal_id']['und']['0']['value']['#value'] = $node->nid; to hook_form_alter in template.php, and the value is populating the field and the form is submitting successfully. Sweet!