Form ajax add more button added via another ajax callback not working I have a form button which I want to add another field with another button on that form( I am able to do this) but second button is not clickable. Any idea. Following is my code-

This is my form code- 

function create_report_form($form, $form_state) {
$form['title'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Report ttitle'),
    '#value' =&gt;'',
);

$form['actions'] = array(
  '#type' =&gt; 'actions',
);

$form['actions']['submit'] = array(
  '#type' =&gt; 'submit',
  '#value' =&gt; t('Save'),
);
$form['conditions'] = array(
  '#tree' =&gt; TRUE,
);
$form['conditions']['report_type'] = array(
  '#title' =&gt; t('Report type'),
  '#type' =&gt; 'select',
  '#prefix'=&gt; '&lt;div class="conditions-wrapper"&gt;&lt;/div&gt;',
  '#multiple' =&gt; false, 
  '#options' =&gt; get_report_type()
); 

 $form['conditions']['submit'] = array(
   '#type' =&gt; 'button',
   '#value' =&gt; t('Add condition'),
   //'#name' =&gt;   '_add_another_outcome',
   '#ajax' =&gt; array(
      'callback' =&gt; 'reports_add_conditions',
      'wrapper' =&gt; 'report-form',
      'method' =&gt; 'replace',
      'effect' =&gt; 'fade',
   ),
  );  
   return $form;
}


Now, when I click on this button it will call the following function and generate another form element(select list) with another button which will call another ajax function (this is what which is not working).

function reports_add_conditions($form, &amp;$form_state){
$values = $form_state['values'];
$form_state['rebuild'] = TRUE;
$type = $values['conditions']['report_type'];
$form['attributes'] = array(
  '#tree' =&gt; TRUE,
);
$form['attributes']['submit'] = array(
    '#type' =&gt; 'button',
    '#value' =&gt; t('Add attribute condition'),
    '#ajax' =&gt; array(
      'callback' =&gt; 'reports_add_attribute_conditions',
      'wrapper' =&gt; 'report-form',
      'method' =&gt; 'replace',
      'effect' =&gt; 'fade',
    ),
);       
$form['attributes']['attribute'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; '',
    '#options' =&gt; get_options($type),
    '#size' =&gt; 22, 
);  
  return drupal_render($form);
}


As you can see from the code I am not able to call "reports_add_attribute_conditions" function for the button. 

This is my second call back code-

function reports_add_attribute_conditions($form, &amp;$form_state){
$form_state['rebuild'] = TRUE;
$values = $form_state['values'];
$type = $values['conditions']['report_type'];
$form['attribute'] = array(
    '#type' =&gt; 'select',
    '#name' =&gt; $type,
    '#title' =&gt; '',
    '#options' =&gt;  get_options($type),
    '#size' =&gt; 22, 
); 
$form['attributes']['submit'] = array(
    '#type' =&gt; 'button',
    '#value' =&gt; t('Add attribute condition'),
    '#ajax' =&gt; array(
      'callback' =&gt; 'reports_add_attribute_conditions',
      'wrapper' =&gt; 'report-form',
      'method' =&gt; 'replace',
      'effect' =&gt; 'fade',
    ),
); 

 return drupal_render($form);
}


Any idea is greatly appreciable
@NabajitRoy my idea is 


Never use drupal_render() manual calls (return $form array as-is)
Move all the form generation code into form constructor( create_report_form() ), AJAX
callback should not create new elements for form but only
create_report_form() should
AJAX callbacks should only return element form (not generate them)
e.g. return $form['attributes']['submit'] and may be
$form_state['rebuild'] = true; if needed.
To know in create_report_form() if it was called by AJAX request
button check the $form_state['triggering_element'] in it.
I feel that using '#type' =&gt; 'submit' instead of '#type' =&gt; 'button'
is better


 https://www.drupal.org/node/752056