public function EntityFormController::form

Returns the actual form array to be built.

See also

Drupal\Core\Entity\EntityFormController::build()

16 calls to EntityFormController::form()
AccountFormController::form in drupal/core/modules/user/lib/Drupal/user/AccountFormController.php
Overrides Drupal\Core\Entity\EntityFormController::form().
ActionFormControllerBase::form in drupal/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php
Returns the actual form array to be built.
CategoryFormController::form in drupal/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
Overrides Drupal\Core\Entity\EntityFormController::form().
ConfigTestFormController::form in drupal/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php
Overrides Drupal\Core\Entity\EntityFormController::form().
CustomBlockTypeFormController::form in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php
Overrides \Drupal\Core\Entity\EntityFormController::form().

... See full list

20 methods override EntityFormController::form()
AccountFormController::form in drupal/core/modules/user/lib/Drupal/user/AccountFormController.php
Overrides Drupal\Core\Entity\EntityFormController::form().
ActionFormControllerBase::form in drupal/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php
Returns the actual form array to be built.
BlockFormController::form in drupal/core/modules/block/lib/Drupal/block/BlockFormController.php
Overrides \Drupal\Core\Entity\EntityFormController::form().
CategoryFormController::form in drupal/core/modules/contact/lib/Drupal/contact/CategoryFormController.php
Overrides Drupal\Core\Entity\EntityFormController::form().
ConfigTestFormController::form in drupal/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php
Overrides Drupal\Core\Entity\EntityFormController::form().

... See full list

File

drupal/core/lib/Drupal/Core/Entity/EntityFormController.php, line 145
Contains \Drupal\Core\Entity\EntityFormController.

Class

EntityFormController
Base class for entity form controllers.

Namespace

Drupal\Core\Entity

Code

public function form(array $form, array &$form_state) {
  $entity = $this->entity;

  // @todo Exploit the Field API to generate the default widgets for the
  // entity properties.
  $info = $entity
    ->entityInfo();
  if (!empty($info['fieldable'])) {
    field_attach_form($entity, $form, $form_state, $this
      ->getFormLangcode($form_state));
  }

  // Assign the weights configured in the form display.
  foreach ($this
    ->getFormDisplay($form_state)
    ->getComponents() as $name => $options) {
    if (isset($form[$name])) {
      $form[$name]['#weight'] = $options['weight'];
    }
  }
  if (!isset($form['langcode'])) {

    // If the form did not specify otherwise, default to keeping the existing
    // language of the entity or defaulting to the site default language for
    // new entities.
    $form['langcode'] = array(
      '#type' => 'value',
      '#value' => !$entity
        ->isNew() ? $entity->langcode : language_default()->langcode,
    );
  }
  return $form;
}