function _drupal_form_id

Determines the form ID.

Parameters

\Drupal\Core\Form\FormInterface|string $form_arg: A form object to use to build the form, or the unique string identifying the desired form. If $form_arg is a string and a function with that name exists, it is called to build the form array.

array $form_state: An associative array containing the current state of the form.

Return value

string The unique string identifying the desired form.

Related topics

3 calls to _drupal_form_id()
drupal_form_submit in drupal/core/includes/form.inc
Retrieves, populates, and processes a form.
drupal_get_form in drupal/core/includes/form.inc
Returns a renderable form array for a given form ID.
HtmlFormController::content in drupal/core/lib/Drupal/Core/Controller/HtmlFormController.php
Controller method for generic HTML form pages.

File

drupal/core/includes/form.inc, line 119
Functions for form and batch generation and processing.

Code

function _drupal_form_id($form_arg, &$form_state) {

  // If the $form_arg implements \Drupal\Core\Form\FormInterface, add that as
  // the callback object and determine the form ID.
  if (is_object($form_arg) && $form_arg instanceof FormInterface) {
    $form_state['build_info']['callback_object'] = $form_arg;
    if ($form_arg instanceof BaseFormIdInterface) {
      $form_state['build_info']['base_form_id'] = $form_arg
        ->getBaseFormID();
    }
    return $form_arg
      ->getFormID();
  }

  // Otherwise, the $form_arg is the form ID.
  return $form_arg;
}