You are here

function party_attached_entity_action_form in Party 8.2

Same name and namespace in other branches
  1. 7 party.pages.inc \party_attached_entity_action_form()

Form builder for a generalized attached entity action.

@todo: let this handle built-in actions: 'edit', 'delete', 'detach'.

Parameters

$party: A loaded party object.

$data_set: A loaded data set. We don't actually need this loaded, but we need a menu loader to convert the path-style string to the machine name, and a menu loader that doesn't load would be weird too.

$action: The machine name of a data set action, as defined by the data set in hook_party_data_set_info().

$eid: The id of the entity, if editing.

1 string reference to 'party_attached_entity_action_form'
party_menu in ./party.module
Implements hook_menu().

File

./party.pages.inc, line 234
party.pages.inc

Code

function party_attached_entity_action_form($form, &$form_state, $party, $data_set, $action, $eid = NULL) {
  $action_controller = new $data_set['actions'][$action]['controller']();

  // Get the page title from the controller.
  $page_title = $action_controller
    ->get_page_title($party, $data_set, $eid);
  drupal_set_title(check_plain($page_title));
  $form += $action_controller
    ->action_form($form, $form_state, $party, $data_set, $eid);

  // Ensure that our submit and validate handlers are run (and run last).
  if (!isset($form['#submit']) || !in_array('party_attached_entity_action_form_submit', $form['#submit'])) {
    $form['#submit'][] = 'party_attached_entity_action_form_submit';
  }
  if (!isset($form['#validate']) || !in_array('party_attached_entity_action_form_validate', $form['#validate'])) {
    $form['#validate'][] = 'party_attached_entity_action_form_validate';
  }
  return $form;
}