I have a form (table with checkboxes) created using theme_tableselect. The form is appearing fine with checkboxes. I need to show confirmation popup/modal before processing the checked rows. I am using ctools for the same and have managed to open the confirmation form in ctools modal/popup but having the issue that form in modal is not submitting and nothing happens except the form action /system/ajax. So my question is how can I submit form in modal or open a confirmation form in modal that submits ? I am using the following code in tableselect form with checkboxes

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Remove selected'),
    '#ajax' => array(
      'callback' => 'multiple_confirm_popup',

and following code to open the popup/modal

    function multiple_confirm_popup($form, &$form_state) {
  $commands = array();
  $selected_checkboxes = $form_state['values']['table'];
  $list_customers = '<ul>';
  $checks = [];
  foreach ($selected_checkboxes as $checkbox_key => $checkbox_val) {
    if($checkbox_val !== 0) {
      $list_customers .= '<li>'.$checkbox_val.'</li>';
      $checks[] = $checkbox_val;
  $list_customers .= '</ul>';
  $commands[] = ctools_modal_command_display('Confirm delele user ?', 'Are you sure you want to delete the user?'.drupal_render(drupal_get_form('multiple_delete_confirm_popup',$checks)));
  print ajax_render($commands);

I have tried to use the following ctools command to render form but it is not working and form is not rendered.

ctools_modal_form_wrapper('multiple_delete_confirm_popup', $form_state);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.