You are here

function views_megarow_form_alter in Views Megarow 7

Implements hook_form_alter().

File

./views_megarow.module, line 427

Code

function views_megarow_form_alter(&$form, &$form_state, $form_id) {

  // Look for node forms, entity forms should be ok.
  if (strstr($form_id, '_node_form')) {

    // Use module_load_include so that caches and stuff can know to load this.
    form_load_include($form_state, 'inc', 'node', 'node.pages');

    // Prevent Drupal from redirecting the user to the node being edited if
    // we are doing the edition action from a megarow.
    if (isset($form['#node']->from_megarow) && $form['#node']->from_megarow == TRUE) {
      $form_state['programmed'] = TRUE;

      // Trigger an extra submit callback offering the possibility to have
      // the megarow automatically closed when the node is submitted.
      $form['actions']['submit']['#submit'][] = 'views_megarow_autoclose_megarow';
    }
  }
  else {
    if ($form_id == 'user_profile_form') {

      // Trigger an extra submit callback offering the possibility to have
      // the megarow automatically closed when the user is submitted if
      // we are doing the edition action from a megarow.
      if (isset($form['#user']->from_megarow) && $form['#user']->from_megarow == TRUE) {
        $form['#submit'][] = 'views_megarow_autoclose_megarow';
      }
    }
  }
}