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' => 'submit',
'#ajax' => array(
'callback' => 'callbackAjax',
),
);
}
function callbackAjax($form, &$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.