Guest User

Untitled

a guest
Oct 20th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1.  // ... $form_state and $form_info all populated now.
  2.  
  3.   if ($js) {
  4.     ctools_include('ajax');
  5.     ctools_include('modal');
  6.  
  7.     // Neither of these 'ajax' or 'modal' seemed to have any affect.
  8.     $form_state['ajax'] = TRUE;
  9.     $form_state['modal'] = TRUE;
  10.     $form_info['ajax'] = TRUE;
  11.     $form_info['modal'] = TRUE;
  12.  
  13.     // This seems to work.
  14.     $form_state['ajax render'] = 'my_module_ajax_render';
  15.    
  16.     $output = ctools_wizard_multistep_form($form_info, $step, $form_state);
  17.  
  18.     if (empty($output)) {
  19.       drupal_set_message('All done.');
  20.       $output[] = ctools_modal_command_dismiss();
  21.     }
  22.    
  23.     // JSON object is returned while ajax render is set as above.
  24.     return $output;
  25.   }
  26.   else {
  27.     // Outputs wizard just fine.
  28.     return ctools_wizard_multistep_form($form_info, $step, $form_state);
  29.   }
  30. }
  31.  
  32.  
  33. function my_module_ajax_render(&$form_state, $output) {
  34.   $messages = theme_status_messages();
  35.   $commands[] = ajax_command_replace("#modal-content", $output);
  36.   return ajax_render($commands);
  37. }
Add Comment
Please, Sign In to add comment