title: How to populate fields on Drupal form API
body: <p>I have  a drupal API of the form </p>
  
  <pre><code>  function contactus(){
      return drupal_get_form('myform_contact');
    }
  
  function myform_contact($form_state){
      $form['field'] = array(
      '#type' =&gt; 'fieldset',
      '#title' =&gt; 'Contact Us Form',
      '#collapsible' =&gt; true,
      '#collapsed'=&gt; false,
      '#description' =&gt; t('Enter your feedback'),
      );
  
      $form['field']['email']  = array(
      '#type'=&gt;'textfield',
      '#title'=&gt; 'E-mail Address',
      '#required' =&gt; '0',
      '#maxlength' =&gt; 127,
      '#required' =&gt; 0,
      );
  
      $form['field']['comment'] = array(
      '#type'=&gt; 'textarea',
      '#rows'=&gt; 5,
      '#title' =&gt; 'Comment / Question? ',
      '#required' =&gt;1,     
      );
  
      $form['field']['captcha'] = array(
      '#type' =&gt; 'captcha',
      '#captcha_type' =&gt; 'image_captcha/Image',
  
      );
  
      $form['field']['submit'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; 'Submit',
      '#validate' =&gt; array('form_validate'),
      '#weight' =&gt; 1
      );
      $form['field']['edit'] = array(
      '#type'=&gt; 'button',
      '#value' =&gt; 'Edit',
      '#validate'=&gt; array('form_edit'),
      '#weight' =&gt; 10,
      );
  
      return $form;
  }
  
  function myform_contact_submit($form, &amp;$form_state){
  
      $txt = $form_state['values']['comment'];
      $email = $form_state['values']['email'];
      $txt = wordwrap($txt,70);
      mail("$email", "Comment / Questions ?", $txt);
      $result = db_query("insert into contactus values('$email','$txt')");
      $node = new stdClass();
      $node-&gt; title = $form_state['values']['email'];
      $node-&gt; body = $form_state['values']['comment'];
      $node-&gt;type = 'contactus';
      node_save($node);
      drupal_set_message(t('Form Successfully submitted with nid of '. $node-&gt;nid));
      drupal_set_message(t('Values inserted into Database'));
  }
  
  function form_edit($form,&amp;$form_state){
     $nid = $form_state['values']['nid'];
     $node = node_load(49);
     drupal_set_message('edit mode with title '. $node-&gt;title. ' and comment as '. $node-&gt;body);
     $form_state['values']['email'] =  $node-&gt;title;
     $form_state['values']['comment'] = $node-&gt;body;     
  }
  </code></pre>
  
  <p>On edit i want to populate the form fields with the values. However, it is not populating. Any ideas??</p>