Need help for Drupal 7 Ajax Add more form elements $form['feedbackmarkup']['feedback']['num_domains'] = array(
    '#type' =&gt; 'hidden',
    '#default_value' =&gt; 1,
);  
       $num = isset($form_state['values']['num_domains']) ? $form_state['values']['num_domains'] : 1;
     for($i = 1; $i &lt;= $num; $i++){
    $form['feedbackmarkup']['feedback']['fname_'.$i] = array(
        '#type' =&gt; 'textfield', 
        '#size' =&gt; 12,
        '#required' =&gt; true,
        '#prefix' =&gt; '&lt;tr&gt;&lt;td&gt;',
        '#suffix' =&gt; '&lt;/td&gt;',
    );
    }
       $form['add_more'] = array(
        '#type' =&gt; 'button',
        '#value' =&gt; t('Add More'),
        '#href' =&gt; '',
        '#ajax' =&gt; array(
           'callback' =&gt; 'for($i = 1; $i &lt;= $num; $i++){
    $form['feedbackmarkup']['feedback']['fname_'.$i] = array(
        '#type' =&gt; 'textfield', 
        '#size' =&gt; 12,
        '#required' =&gt; true,
        '#prefix' =&gt; '&lt;tr&gt;&lt;td&gt;',
        '#suffix' =&gt; '&lt;/td&gt;',
    );',
           'wrapper' =&gt; 'feedback_replace',
         ),
       );


and In my Ajax callback function 

  function ajax_example_simplest_callback($form, $form_state) {
         $test = isset($form_state['values']['num_domains']) ? $form_state['values']['num_domains']+1 : 1;
        $form['feedbackmarkup']['feedback']['num_domains']['#value'] = $test;
       drupal_set_message(print_r($form_state['values'],true)); //It is printing form_state with values but not adding my fields above in for loop
        return $form['feedbackmarkup']['feedback'];
}
It was not adding my field because #required is set to true. Now I removed it, and my problem is solved.