You are here

function party_attached_entity_edit_form_render in Party 7

Same name and namespace in other branches
  1. 8.2 plugins/content_types/party_attached_entity_edit_form.inc \party_attached_entity_edit_form_render()

Render the Party Attached Entity Edit Form

Parameters

$subtype:

$conf: Configuration as done at admin time

$args:

$context: Context - in this case we don't have any

Return value

An object with at least title and content members

1 string reference to 'party_attached_entity_edit_form_render'
party_attached_entity_edit_form.inc in plugins/content_types/party_attached_entity_edit_form.inc
CTools content for user edit form

File

plugins/content_types/party_attached_entity_edit_form.inc, line 44
CTools content for user edit form

Code

function party_attached_entity_edit_form_render($subtype, $conf, $args, $context) {
  $data_sets = party_get_data_set_info();
  $data_set = isset($conf['data_set_name']) && isset($data_sets[$conf['data_set_name']]) ? $data_sets[$conf['data_set_name']] : NULL;
  $block = new stdClass();
  $block->title = t('Edit Party Attached Entity');
  $block->content = '';
  if (!empty($context->data) && $data_set) {

    // Get our controller
    $controller = $context->data
      ->getDataSetController($data_set['set_name']);

    // Get our entity
    $attached_entity = $controller
      ->getEntity(0, !empty($conf['create']));
    if (!empty($conf['create']) && !empty($attached_entity)) {
      $controller
        ->attachEntity($attached_entity);
    }

    // If there's no attached_entity return an empty block
    if (!$attached_entity) {
      return $block;
    }
    $form = drupal_get_form('party_attached_entity_edit_form_form__' . $data_set['set_name'] . '__' . 0, $context->data, $data_set, 0);

    // Render it...
    $block->content = drupal_render($form);
  }
  return $block;
}