You are here

function flagging_dialog_form_alter in Flagging Form 7.3

Same name and namespace in other branches
  1. 7 flagging_dialog.module \flagging_dialog_form_alter()

Implements hook_form_alter().

File

./flagging_dialog.module, line 141
Provides menu callbacks for displaying the flagging forms in a dialog box.

Code

function flagging_dialog_form_alter(&$form, &$form_state, $form_id) {
  if (!empty($form_state['flag_is_using_ajax'])) {

    // Make the buttons submit via ajax. (This could also be done by adding
    // class="use-ajax-submit" to buttons, but bugs in Drupal's misc/ajax.js
    // prevent this from working.)
    if (isset($form['actions'])) {
      foreach (element_children($form['actions']) as $button) {

        // For performance, we handle cancel buttons in our JavaScript.
        if ($button != 'cancel') {
          $form['actions'][$button]['#ajax']['path'] = $_GET['q'];
        }
      }
    }

    // Make sure #ids don't clash with existing ones.
    $form = dialog_process_ajax_form($form);
  }
}