Guest User

Untitled

a guest
Oct 22nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. function subhub_magicapi_2_app_block_form_ajax_callback(&$form, &$form_state) {
  2.  
  3. $commands['#type'] = 'ajax';
  4. $commands['#commands'][] = ajax_command_insert(NULL, drupal_render($form['settings']));
  5. $commands['#commands'][] = ajax_command_prepend(NULL, theme('status_messages'));
  6.  
  7. // If the form was validated & submitted, dismiss the dialogue & replace the block.
  8. if($form_state['executed']) {
  9.  
  10. // Un-dialogue the dialogue.
  11. $commands['#commands'][] = ajax_command_invoke('div.settings', 'dialog', array('destroy'));
  12.  
  13. // Remove it from the DOM.
  14. $commands['#commands'][] = ajax_command_remove('div.settings');
  15.  
  16. // Reload the block that we've altered
  17. $delta = $form_state['build_info']['args'][0];
  18. $rendered_block = subhub_magicapi_2_block_renderer($delta);
  19.  
  20. $instance = subhub_magicapi_2_split_delta($delta);
  21.  
  22. // Using the block id to replace here doesn't work for some reason...
  23. $commands['#commands'][] = ajax_command_replace('div.mbid-' . $instance['mbid'], $rendered_block);
  24. }
  25.  
  26. return $commands;
  27. }
Add Comment
Please, Sign In to add comment