You are here

function party_attached_entity_edit_form in Party 7

Same name and namespace in other branches
  1. 8.2 party.pages.inc \party_attached_entity_edit_form()

Form to edit or create an attached entity.

@todo: Reimplement actions and edit overlay stuff

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.

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

1 call to party_attached_entity_edit_form()
party_attached_entity_edit_form_form in plugins/content_types/party_attached_entity_edit_form.inc
Form
2 string references to 'party_attached_entity_edit_form'
party_attached_entity_edit_form.inc in plugins/content_types/party_attached_entity_edit_form.inc
CTools content for user edit form
party_menu in ./party.module
Implements hook_menu().

File

./party.pages.inc, line 355
party.pages.inc

Code

function party_attached_entity_edit_form($form, &$form_state, $party, $data_set, $delta = NULL) {

  // Add the file to build info incase this has been embedded from somewhere else.
  $form_state['build_info']['files'][] = drupal_get_path('module', 'party') . '/party.pages.inc';
  $data_set_controller = $party
    ->getDataSetController($data_set['set_name']);
  if (isset($delta)) {
    $entity = $data_set_controller
      ->getEntity($delta, TRUE);
    $form_title = t("Edit @data-set-label (@entity-label)", array(
      '@data-set-label' => $data_set['label'],
      '@entity-label' => entity_label($data_set['entity type'], $entity),
    ));
  }
  else {
    $entity = $data_set_controller
      ->createEntity();
    $data_set_controller
      ->attachEntity($entity);
    $delta = $data_set_controller
      ->getEntityDelta($entity);
    $form_title = t("Add @data-set-label to @party-label", array(
      '@data-set-label' => $data_set_controller
        ->getDataInfo('label'),
      '@party-label' => $party->label,
    ));
  }
  drupal_set_title($form_title);

  // Get the attached entity form as a standalone, as we have just the one.
  party_data_set_attach_form($form, $form_state, $data_set_controller, array(
    $delta,
  ), TRUE);

  // As we know we're only dealine with one item remove the fieldset.
  $form_key = $data_set_controller
    ->getDataInfo('name') . ':' . $delta;
  unset($form[$form_key]['#type'], $form[$form_key]['#title']);
  $form['#submit'][] = 'party_attached_entity_edit_form_submit';
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 99,
  );
  return $form;
}