You are here

function ajax_load_example_form in Ajax Load 6.2

Generate a sample form.

1 string reference to 'ajax_load_example_form'
ajax_load_example_callback in ajax_load_example/ajax_load_example.page.inc
Render a form in JSON.

File

ajax_load_example/ajax_load_example.page.inc, line 50
Menu callbacks and associated methods for Ajax load example.

Code

function ajax_load_example_form() {
  $form = array(
    '#prefix' => t('This form tests whether additional Javascript and CSS files were loaded via AJAX. Expected results: form has a grey border (via a new CSS instruction); form element Javascript is functional; the message "Ajax load example inline script called" appears below (via an inline script).'),
    '#suffix' => t('Submit button intentionally left out--nothing to submit.'),
  );

  // Add a sample inline script. This alert should be called after all scripts have
  // been added.
  drupal_add_js("\$('#ajax-load-example-form').prepend('<p>" . t('Ajax load example inline script called.') . "</p>');", 'inline');
  drupal_add_css(drupal_get_path('module', 'ajax_load_example') . '/ajax_load_example.css');
  $form['fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Sample collapsible fieldset'),
    '#collapsible' => TRUE,
  );
  $form['fieldset']['textarea'] = array(
    '#type' => 'textarea',
    '#title' => t('Sample expandable fieldset'),
  );
  $form['fieldset']['autocomplete'] = array(
    '#type' => 'textfield',
    '#autocomplete_path' => 'user/autocomplete',
    '#size' => '6',
    '#maxlength' => '7',
    '#title' => t('Sample user autocomplete'),
  );

  // Submit element intentionally omitted.
  return $form;
}