home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (form_test.file.inc)

This example Drupal source code file (form_test.file.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

ajax_wrapper_id, array, callback, div, form, form_state, form_test_load_include_menu_ajax, form_test_load_include_submit, function, php, return, submit, type, value

The form_test.file.inc Drupal example source code

// $Id: form_test.file.inc,v 1.4 2010/09/19 18:39:18 dries Exp $

 * @file
 * An include file to test loading it with the form API.

 * Form constructor for testing FAPI file inclusion of the file specified in
 * hook_menu().
function form_test_load_include_menu($form, &$form_state) {
  // Submit the form via AJAX. That way the FAPI has to care about including
  // the file specified in hook_menu().
  $ajax_wrapper_id = drupal_html_id('form-test-load-include-menu-ajax-wrapper');
  $form['ajax_wrapper'] = array(
    '#markup' => '<div id="' . $ajax_wrapper_id . '"></div>',
  $form['button'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#submit' => array('form_test_load_include_submit'),
    '#ajax' => array(
      'wrapper' => $ajax_wrapper_id,
      'method' => 'append',
      'callback' => 'form_test_load_include_menu_ajax',
  return $form;

 * Submit callback for the form API file inclusion test forms.
function form_test_load_include_submit($form, $form_state) {
  drupal_set_message('Submit callback called.');

 * Ajax callback for the file inclusion via menu test.
function form_test_load_include_menu_ajax($form) {
  // We don't need to return anything, since #ajax['method'] is 'append', which
  // does not remove the original #ajax['wrapper'] element, and status messages
  // are automatically added by the AJAX framework as long as there's a wrapper
  // element to add them to.
  return '';

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal form_test.file.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.