function ctools_entity_form_field_content_type_render

Render the custom content type.

File

plugins/content_types/form/entity_form_field.inc, line 98

Code

function ctools_entity_form_field_content_type_render($subtype, $conf, $panel_args, $context) {
  if (empty($context) || empty($context->data)) {
    return;
  }
  // Get a shortcut to the entity.
  $entity = $context->data;
  list($entity_type, $field_name) = explode(':', $subtype, 2);
  // Load the entity type's information for this field.
  $ids = entity_extract_ids($entity_type, $entity);
  $field = field_info_instance($entity_type, $field_name, $ids[2]);
  // Check for field groups.
  if (empty($field) && module_exists('field_group')) {
    $groups = field_group_info_groups($entity_type, $entity->type, "form");
    $group = !empty($groups[$field_name]) ? $groups[$field_name] : NULL;
  }
  // Do not render if the entity type does not have this field or group.
  if (empty($field) && empty($group)) {
    return;
  }
  $block = new stdClass();
  if (isset($context->form)) {
    $block->content = array();
    if (!empty($field)) {
      $block->content[$field_name] = $context->form[$field_name];
      unset($context->form[$field_name]);
    }
    else {
      // Pre-render the form to populate field groups.
      if (isset($context->form['#pre_render'])) {
        foreach ($context->form['#pre_render'] as $function) {
          if (function_exists($function)) {
            $context->form = $function($context->form);
          }
        }
        unset($context->form['#pre_render']);
      }
      $block->content[$field_name] = $context->form[$field_name];
      unset($context->form[$field_name]);
    }
  }
  else {
    $block->content = t('Entity info.');
  }
  return $block;
}