8.3.x FormStateInterface.php public FormStateInterface::loadInclude($module, $type, $name = NULL)
8.0.x FormStateInterface.php public FormStateInterface::loadInclude($module, $type, $name = NULL)
8.1.x FormStateInterface.php public FormStateInterface::loadInclude($module, $type, $name = NULL)
8.2.x FormStateInterface.php public FormStateInterface::loadInclude($module, $type, $name = NULL)
8.4.x FormStateInterface.php public FormStateInterface::loadInclude($module, $type, $name = NULL)

Ensures an include file is loaded whenever the form is processed.

Example:

  // Load node.admin.inc from Node module.
  $form_state->loadInclude('node', 'inc', '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, this method makes sure the include file is correctly loaded also if the form is cached.

Parameters

string $module: The module to which the include file belongs.

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

string|null $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

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

See also

module_load_include()

1 method overrides FormStateInterface::loadInclude()
FormState::loadInclude in core/lib/Drupal/Core/Form/FormState.php
Ensures an include file is loaded whenever the form is processed.

File

core/lib/Drupal/Core/Form/FormStateInterface.php, line 73

Class

FormStateInterface
Provides an interface for an object containing the current state of a form.

Namespace

Drupal\Core\Form

Code

public function loadInclude($module, $type, $name = NULL);