Returns the actual form array to be built.
Drupal\Core\Entity\EntityFormController::build()
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;
}