You are here

function entity_translation_edit_form_info in Entity Translation 7

Returns an array of edit form info as defined in hook_entity_info().

Parameters

$form: The entity edit form.

$form_state: The entity edit form state.

Return value

An edit form info array containing the entity to be translated in the 'entity' key.

4 calls to entity_translation_edit_form_info()
entity_translation_entity_form_get_handler in ./entity_translation.module
Returns the translation handler wrapping the entity being edited.
entity_translation_form_alter in ./entity_translation.module
Implements hook_form_alter().
entity_translation_i18n_menu_form in entity_translation_i18n_menu/entity_translation_i18n_menu.module
Menu specific alterations for the entity form.
entity_translation_test_form_alter in tests/entity_translation_test.module
Implements hook_form_alter().

File

./entity_translation.module, line 1953

Code

function entity_translation_edit_form_info($form, $form_state) {
  $info = FALSE;
  $entity_type = isset($form['#entity_type']) && is_string($form['#entity_type']) ? $form['#entity_type'] : FALSE;
  if ($entity_type) {
    $entity_info = entity_get_info($form['#entity_type']);
    if (!empty($entity_info['translation']['entity_translation']['edit form'])) {
      $entity_keys = explode('][', $entity_info['translation']['entity_translation']['edit form']);
      $key_exists = FALSE;
      $entity = drupal_array_get_nested_value($form_state, $entity_keys, $key_exists);
      if ($key_exists) {
        $info = array(
          'entity type' => $form['#entity_type'],
          'entity' => (object) $entity,
        );
      }
    }
  }
  return $info;
}