function entity_form_state_defaults

Returns the default form state for the given entity and operation.

Parameters

EntityInterface $entity: The entity to be created or edited.

$operation: (optional) The operation identifying the form to be processed.

Return value

A $form_state array already filled the entity form controller.

2 calls to entity_form_state_defaults()
entity_form_submit in drupal/core/includes/entity.inc
Retrieves, populates, and processes an entity form.
entity_get_form in drupal/core/includes/entity.inc
Returns the built and processed entity form for the given entity.

File

drupal/core/includes/entity.inc, line 442
Entity API for handling entities like nodes or users.

Code

function entity_form_state_defaults(EntityInterface $entity, $operation = 'default') {
  $form_state = array();
  $controller = Drupal::entityManager()
    ->getFormController($entity
    ->entityType(), $operation);
  $controller
    ->setEntity($entity);
  $form_state['build_info']['callback_object'] = $controller;
  $form_state['build_info']['base_form_id'] = $controller
    ->getBaseFormID();
  $form_state['build_info']['args'] = array();
  return $form_state;
}