1. drupal
    1. 8
    2. 7
7 – 8 form_load_include(&$form_state, $type, $module, $name = NULL)

Loads an include file and makes sure it is loaded whenever the form is processed.


  // Load from Node module.
  form_load_include($form_state, 'inc', 'node', 'node.admin');

Use this function instead of module_load_include() from inside a form constructor or any form processing logic as it ensures that the include file is loaded whenever the form is processed. In contrast to using module_load_include() directly, form_load_include() makes sure the include file is correctly loaded also if the form is cached.


$form_state The current state of the form.

$type The include file's type (file extension).

$module The module to which the include file belongs.

$name (optional) The base file name (without the $type extension). If omitted, $module is used; i.e., resulting in "$module.$type" by default.

Return value

The filepath of the loaded include file, or FALSE if the include file was not found or has been loaded already.

See also


Related topics


includes/, line 595

function form_load_include(&$form_state, $type, $module, $name = NULL) {
  if (!isset($name)) {
    $name = $module;
  if (!isset($form_state['build_info']['files']["$module:$name.$type"])) {
    // Only add successfully included files to the form state.
    if ($result = module_load_include($type, $module, $name)) {
      $form_state['build_info']['files']["$module:$name.$type"] = array(
        'type' => $type, 
        'module' => $module, 
        'name' => $name,
      return $result;
  return FALSE;