title: Drupal Form:want to show previous form value as default_value on page
body: <p>My Goal is if user is submitting this form with "Product Name" value as "YYY". On submit page should reload but this time "Product Name" should show previous valye as default as in this case "YYY".</p>
  
  <p>Here is my code...</p>
  
  <pre><code>function addnewproduct_page () {
    return drupal_get_form('addnewproduct_form',&amp;$form_state);
  }
  
  function addnewproduct_form(&amp;$form_state) {
    $form = array();
  
  
      $formproductname['productname'] = array (
      '#type' =&gt; 'textfield',
      '#title' =&gt; t('Product Name'),
      '#required' =&gt; TRUE,
          '#size' =&gt; '20',
    );
  
      if (isset($form_state['values']['productname'])) 
      {
      $form['productname']['#default_value'] = $form_state['values']['productname'];
    }
  
    //a "submit" button
    $form['submit'] = array (
      '#type' =&gt; 'submit',
      '#value' =&gt; t('Add new Product'),  
    );
    return $form;
  }
  </code></pre>