You are here

function entity_ui_form_defaults in Entity API 7

Form wrapper callback for all entity ui forms.

This callback makes sure the form state is properly initialized and sets some useful default titles.

See also

EntityDefaultUIController::hook_forms()

1 call to entity_ui_form_defaults()
entity_ui_main_form_defaults in includes/entity.ui.inc
Form wrapper the main entity form.
1 string reference to 'entity_ui_form_defaults'
EntityDefaultUIController::hook_forms in includes/entity.ui.inc
Provides definitions for implementing hook_forms().

File

includes/entity.ui.inc, line 688
Provides a controller for building an entity overview form.

Code

function entity_ui_form_defaults($form, &$form_state, $entity_type, $entity = NULL, $op = NULL) {
  $defaults = array(
    'entity_type' => $entity_type,
  );
  if (isset($entity)) {
    $defaults[$entity_type] = $entity;
  }
  if (isset($op)) {
    $defaults['op'] = $op;
  }
  $form_state += $defaults;
  if (isset($op)) {
    drupal_set_title(entity_ui_get_page_title($op, $entity_type, $entity), PASS_THROUGH);
  }

  // Add in handlers pointing to the controller for the forms implemented by it.
  if (isset($form_state['build_info']['base_form_id']) && $form_state['build_info']['base_form_id'] != $entity_type . '_form') {
    $form['#validate'][] = 'entity_ui_controller_form_validate';
    $form['#submit'][] = 'entity_ui_controller_form_submit';
  }
  return $form;
}