Re-submit form after confirmed AJAX form I have a form with submit AJAX button. When clicking this button, it calls function callbackAjax(). In this function callback, I checked a condition A to show a warning dialog if A is FALSE. The warning dialog has a message and two buttons, Confirm and Cancel. Cancel action will close dialog and do nothing. Confirm action will continue doing the callback function with condition A is true.

function renderForm($form, $form_state) {
  $form['submit'] = array(
    '#type'  =&gt; 'submit',
    '#ajax'  =&gt; array(
      'callback' =&gt; 'callbackAjax',
    ),
  );
}

function callbackAjax($form, &amp;$form_state) {
  if (!$condition) {
    // Show dialog with confirm button
    // If confirmed, doing code in else clause
  }
  else {
    // Save data
  }
}


Please tell me how to re-submit form to save data after I clicked button Confirm which be rendered from AJAX callback?

I tried to set button Confirm as same as Submit button from main from, to call AJAX again, but it shows error.

Thanks for your help.
I found the solution, at least it worked in my case. I want to share if someone need it.

function renderForm($form, $form_state) {
  $form['submit'] = array(
    '#type'  =&gt; 'submit',
    '#ajax'  =&gt; array(
      'callback' =&gt; 'callbackAjax',
    ),
  );
}

function callbackAjax($form, &amp;$form_state) {
  if (empty($form['#skip_validate']) &amp;&amp; !$condition) {
    // Show dialog with confirm button
    // If confirmed, doing code in else clause
    $confirm_form = drupal_get_form('renderConfirmForm', $form, $form_state);
    $commands[] = ajax_command_open_dialog($confirm_form);
  }
  else {
    // Save data
  }
  ...
}

function renderConfirmForm($form, &amp;$form_state, $main_form, $main_form_state) {
  $form['continue'] = array(
    ...
    '#ajax'  =&gt; array(
      'callback' =&gt; 'renderConfirmFormCallback',
    ),
  );
  $form['close'] = ...;
  $main_form['#skip_validate'] = TRUE;
  $form['#main_form'] = $main_form;
  $form['#main_form_state'] = $main_form_state;
  return $form;
}

function renderConfirmFormCallback($form, &amp;$form_state) {
  callbackAjax($form['#main_form'], $form['#main_form_state']);
}