summaryrefslogtreecommitdiff
path: root/sites/all/modules/wysiwyg/tests/wysiwyg_test.module
blob: c2dd9a917af3a43bf7830c5872d91d8bfc9adaa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php

/**
 * @file
 * Testing functionality for Wysiwyg module.
 */

/**
 * Implements hook_menu().
 */
function wysiwyg_test_menu() {
  $items['wysiwyg-test/ajax'] = array(
    'title' => 'Ajaxified form',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('wysiwyg_test_ajax_form'),
    'access callback' => TRUE,
  );
  return $items;
}

/**
 * Form constructor for an ajaxified form lazy-loading a textarea.
 */
function wysiwyg_test_ajax_form($form, &$form_state) {
  $form['enable'] = array(
    '#type' => 'checkbox',
    '#title' => 'Load textarea',
    '#ajax' => array(
      'callback' => 'wysiwyg_test_ajax_form_callback',
      'wrapper' => 'ajax-wrapper',
    ),
  );
  $form['wrapper'] = array(
    '#type' => 'container',
    '#id' => 'ajax-wrapper',
  );
  return $form;
}

/**
 * #ajax callback for wysiwyg_test_ajax_form().
 */
function wysiwyg_test_ajax_form_callback($form, &$form_state) {
  $form['body'] = array(
    '#type' => 'text_format',
    '#default_value' => '',
  );
  form_builder($form['form_id']['#value'], $form, $form_state);
  return $form['body'];
}