@NabajitRoy my idea is
- Never use drupal_render()
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()create_report_form()
should - AJAX callbacks should only return element form (not generetegenerate them)
e.g. return $form['attributes']['submit']
$form['attributes']['submit']
and may be $form_state['rebuild'] = true;$form_state['rebuild'] = true;
if needed. - To know in create_report_form()
create_report_form()
if it was called by AJAX request button check the $form_state['triggering_element']$form_state['triggering_element']
in it. - I feel that using '#type' => 'submit'
'#type' => 'submit'
instead of '#type' => 'button''#type' => 'button'
is better