In my views custom field I have php code that outputs a form.

 $thenid = $data->nid;
 module_load_include('inc', 'dummy_mod', 'dummy'); 
 $output = drupal_get_form('dummy',$thenid);
 print $output;
  

This code works the form is displayed and all the values are correct. But when I submit the form the output is always based on the data values from the first row off results. I am a novice, so sorry if this is a dumb question, but I could use some help

This is the code for the form.

function dummy(&$form_state, $thenid) {
  $node = node_load($thenid);
  $form = array(); 
  $form['nid'] = array('#type' => 'value', '#value' => $node->nid);
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Show Message node Id is ').$form['nid']['#value'],
    '#submit' => array('dummy_submit'),
  );
  return $form; 
}

/**
 * Submit handler for the dummy form.
 */
function dummy_submit($form, &$form_state) {
  drupal_set_message(t('node id from form state is').$form_state['values']['nid']); 
}

Comments

bneel’s picture

Hi,
Did you find a solution ?
Ben

bneel’s picture

It can be resolved following this : http://drupal.org/node/1474898#comment-5765006