You are here

function entity_metadata_form_entity_ui in Entity API 7

Callback to get the form for entities using the entity API admin ui.

1 call to entity_metadata_form_entity_ui()
entity_form in ./entity.module
Gets the edit form for any entity.

File

modules/callbacks.inc, line 1059
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_form_entity_ui($entity, $entity_type) {
  $info = entity_get_info($entity_type);
  $form_state = form_state_defaults();

  // Add in the include file as the form API does else with the include file
  // specified for the active menu item.
  if (!empty($info['admin ui']['file'])) {
    $path = isset($info['admin ui']['file path']) ? $info['admin ui']['file path'] : drupal_get_path('module', $info['module']);
    $form_state['build_info']['files']['entity_ui'] = $path . '/' . $info['admin ui']['file'];

    // Also load the include file.
    if (file_exists($form_state['build_info']['files']['entity_ui'])) {
      require_once DRUPAL_ROOT . '/' . $form_state['build_info']['files']['entity_ui'];
    }
  }
  return entity_ui_get_form($entity_type, $entity, $op = 'edit', $form_state);
}