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.

3 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.
translation_entity_add_page in drupal/core/modules/translation_entity/translation_entity.pages.inc
Page callback for the translation addition page.

File

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

Code

function entity_form_state_defaults(EntityInterface $entity, $operation = 'default', $langcode = NULL) {
  $form_state = array();
  $controller = entity_form_controller($entity
    ->entityType(), $operation);
  $form_state['build_info']['callback'] = array(
    $controller,
    'build',
  );
  $form_state['build_info']['base_form_id'] = $entity
    ->entityType() . '_form';
  $form_state['build_info']['args'] = array(
    $entity,
  );
  $form_state['langcode'] = $langcode;
  return $form_state;
}