Setting field values according to user input in a custom form? i am using FAPI to create nodes through a custom form. the code below creates the nodes and assign them with a title and a body, so if i wanted static field values everything was perfect. my problem is, i want the value of $body_text to be determined by the user's input in the "order" textfield. i tried doing something like -

$body_text = $form['name'];


but that didn't work.

this is the code i'm using -

&lt;?php
function nodeform_menu() {
  $items = array();
  $items['nodeform/form'] = array(
    'title' =&gt; t('My form'),
    'page callback' =&gt; 'nodeform_form',
    'access arguments' =&gt; array('access content'),
    'description' =&gt; t('My form'),
    'type' =&gt; MENU_CALLBACK,
  );
  return $items;
}

function nodeform_form() {
  return drupal_get_form('nodeform_my_form');

}

function nodeform_my_form($form, &amp;$form_state) {

  $form['box'] = array(
    '#type' =&gt; 'markup',
    '#prefix' =&gt; '&lt;div id="box"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
    '#markup' =&gt; '&lt;h1&gt;Initial markup for box&lt;/h1&gt;',
  );

    $form['order'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('My order'),
    '#default_value' =&gt; 'Products',
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#ajax' =&gt; array(
      'callback' =&gt; 'ajax_example_submit_driven_callback',
      'wrapper' =&gt; 'box',
      'name' =&gt; 'submit1',
    ),
    '#value' =&gt; t('Submit'),
  );



$body_text = $form['order'];
$node = new StdClass();
$node-&gt;type = 'page';
$node-&gt;status = 1;
$node-&gt;title = "name";
  $node-&gt;language = LANGUAGE_NONE;
  $node-&gt;body[$node-&gt;language][0]['value']   = $body_text; 
  $node-&gt;language = LANGUAGE_NONE;

node_save($node);
  return $form;
}


can anyone help me understand how to do this? i tried googling and reading the FAPI guide's but couldn't figure it out... plus, this is the first time i am using FAPI so in-spite the code is working, if anyone have any insights on this code (such as coding it more properly) i would also very appreciate that.
You should put node creating into form submit function. In your case it should be nodeform_my_form_submit. You can read more about it here under "Submitting Forms". Btw, you can use 
drupal_get_form as page callback function and with that skip using separate function.