Form is not submitting after ajax callback I have a form which has a checkboxes field.

This field has an ajax callback attached

$form['checkboxes'] = array(
  '#type' =&gt; 'checkboxes',
  '#title' =&gt; 'test',
  '#ajax' =&gt; array(
    'callback' =&gt; 'mymodule_ajax_callback',
    'wrapper' =&gt; 'test-wrapper',
    'method' =&gt; 'replace'
  );
);

function mymodule_ajax_callback(&amp;form, &amp;$form_state) {
  return $form['another-field'];
}


When I check a checkbox, the ajax callback is executed. Then when I try to submit the form through form submit button, it reloads the same page with values in the fields, but the form is not submitted.

I have tried $form_state['rebuild'] = TRUE in the ajax callback also but it did not help.

I have added the #name and #id properties also to the submit button but no luck.

Is there any other solution which I can try?
I think the problem is that you only return the another-field in the ajax callback.

You probably have to make a wrapper for the submit and the another-field.

So you willl have:

$form['ajax_wrapper'] = array(
  'submit' =&gt; array(
    // Submit button...
  ),
  'another-field' =&gt; array(
    // Another field...
  ),
);


And then return $form['ajax_wrapper'] in your ajax callback.
Make sure to use $form_state['rebuild'] = TRUE;