Get the value of a form element returned from an ajax callback function I have a select element and submit button in my form :

$form = array();

$form['myid_template'] = array(
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('Select Template'),    
    '#suffix' =&gt; '&lt;div id="myid_dynamic_input_information"&gt;&lt;/div&gt;',
); 

$form['myid_template']['template_options'] = array(
    '#type' =&gt; 'select',        
    '#options' =&gt; array(
         1 =&gt; t("Student"),
         2 =&gt; t("Employee"),         
     ),
     '#default_value' =&gt; 1,
     '#title' =&gt; t('Select'),                  
     '#ajax' =&gt; array(
         'callback' =&gt; 'myid_select_template',
         'wrapper' =&gt; 'myid_dynamic_input_information',
     ),                             
); 

 $form['submit'] = array(
     '#type' =&gt; 'submit',
     '#value' =&gt; 'Save',         
     '#ajax' =&gt; array(
         'event' =&gt; 'click',
         'callback' =&gt; 'myid_user_page_form_ajax_submit',                     
     ),     
 ); 


My select form element calls an ajax function myid_select_template that adds a field and updates the form.

function myid_select_template($form, $form_state){
      $form = array();
      $form['form']= array(
          '#type' =&gt; 'fieldset',       
          '#title' =&gt; t("Employee's Information"),                
      );     

      $form['form']['template2_field1'] = array(
          '#title' =&gt; t('GSIS No.'),
          '#type' =&gt; 'textfield',    
          '#description' =&gt; "Government Service Insurance System number.",   
          '#attributes' =&gt; array(
              'id' =&gt; $template . '_field1' ,
          ),
      );
      return $form;
}


My problem is, after myid_select_template is called, whenever I click the submit button , I cant access $form['form']['template2_field1'] from myid_user_page_form_ajax_submit callback function.

function myid_user_page_form_ajax_submit($form, &amp;$form_state) { 
    dsm($form);
    dsm($form_state);
}


I did try to display my $form and $form_state variables but I cant find the value of $form['form']['template2_field1'] in it. What should I do? Does it have connection in rebuilding the form? Do I have to rebuild the form to update the $form_statevariable? If yes, how?
I too not sure why the name attribute is not adding to the field. but you can bring by explicitly defining the name in the field.

 $form['form']['template2_field1'] = array(
      '#title' =&gt; t('GSIS No.'),
      '#type' =&gt; 'textfield',
      '#name' =&gt; 'template2_field1',    
      '#description' =&gt; "Government Service Insurance System number.",   
      '#attributes' =&gt; array(
          'id' =&gt; $template . '_field1' ,
      ),
  );