function ajax_test_dialog

Menu callback: Renders a form elements and links with #ajax['dialog'].

1 string reference to 'ajax_test_dialog'
ajax_test_menu in drupal/core/modules/system/tests/modules/ajax_test/ajax_test.module
Implements hook_menu().

File

drupal/core/modules/system/tests/modules/ajax_test/ajax_test.module, line 110
Helper module for Ajax framework tests.

Code

function ajax_test_dialog() {

  // Add two wrapper elements for testing non-modal dialogs. Modal dialogs use
  // the global drupal-modal wrapper by default.
  $build['dialog_wrappers'] = array(
    '#markup' => '<div id="ajax-test-dialog-wrapper-1"></div><div id="ajax-test-dialog-wrapper-2"></div>',
  );

  // Dialog behavior applied to a button.
  $build['form'] = drupal_get_form('ajax_test_dialog_form');

  // Dialog behavior applied to a #type => 'link'.
  $build['link'] = array(
    '#type' => 'link',
    '#title' => 'Link 1 (modal)',
    '#href' => 'ajax-test/dialog-contents',
    '#attributes' => array(
      'class' => array(
        'use-ajax',
      ),
      'data-accepts' => 'application/vnd.drupal-modal',
    ),
  );

  // Dialog behavior applied to links rendered by theme_links().
  $build['links'] = array(
    '#theme' => 'links',
    '#links' => array(
      'link2' => array(
        'title' => 'Link 2 (modal)',
        'href' => 'ajax-test/dialog-contents',
        'attributes' => array(
          'class' => array(
            'use-ajax',
          ),
          'data-accepts' => 'application/vnd.drupal-modal',
          'data-dialog-options' => json_encode(array(
            'width' => 400,
          )),
        ),
      ),
      'link3' => array(
        'title' => 'Link 3 (non-modal)',
        'href' => 'ajax-test/dialog-contents',
        'attributes' => array(
          'class' => array(
            'use-ajax',
          ),
          'data-accepts' => 'application/vnd.drupal-dialog',
          'data-dialog-options' => json_encode(array(
            'target' => 'ajax-test-dialog-wrapper-1',
            'width' => 800,
          )),
        ),
      ),
      'link4' => array(
        'title' => 'Link 4 (close non-modal if open)',
        'href' => 'ajax-test/dialog-close',
        'attributes' => array(
          'class' => array(
            'use-ajax',
          ),
        ),
      ),
    ),
  );
  return $build;
}