How can I use one (or more) of the fields that I get as output from my view to fill in the embedded form? In my case I want to take the body of a node (the views query result) and use that as input in a vef form field. Is there an easy way to do this?

Comments

escore’s picture

Status: Active » Fixed

OK, so trial and error (lots of print_r) made me understand more about the forms api. The trick was to use $row as input to my form declaration. Here's my solution:

function my_test_my_form(&$form_state, $row) {

  $form['post'] = array(
    '#type' => 'textarea',
    '#default_value' => trim($row->node_revisions_body),
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit'
  );
 
  return $form;
}

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

kaod’s picture

Thank you escore. Your solution solved my issue of retrieving variables in other cells within the row. Thank you very much for posting your solution.