You are here

function views_megarow_autoclose_megarow in Views Megarow 7

Submit callback to trigger the megarow closing after submitting the form.

2 string references to 'views_megarow_autoclose_megarow'
views_megarow_form_alter in ./views_megarow.module
Implements hook_form_alter().
views_megarow_form_wrapper in ./views_megarow.module
Wrap a form so that we can use it properly with AJAX. Essentially if the form wishes to render, it automatically does that, otherwise it returns so we can see submission results.

File

./views_megarow.module, line 456

Code

function views_megarow_autoclose_megarow($form, &$form_state) {

  // Check if the user enabled the feature to automatically close the megarow
  // once a form is submitted.
  if (isset($_SESSION['views_megarow']) && $_SESSION['views_megarow']['autoclose']) {
    if (strstr($form['#form_id'], '_node_form')) {
      $output = views_megarow_command_dismiss($form_state['node']->nid);
    }
    else {
      if ($form['#form_id'] == 'user_profile_form') {
        $output = views_megarow_command_dismiss($form_state['user']->uid);
      }
      else {
        if (isset($form_state['#entity_id'])) {
          $output = views_megarow_command_dismiss($form_state['#entity_id']);
        }
      }
    }

    // Turn off the light before leaving.
    print ajax_render(array(
      $output,
    ));
    drupal_exit();
  }
}