You are here

function entity_entity_view_content_type_edit_form in Entity API 7

Returns an edit form for a entity.

Rendered entity use entity types machine name as subtype name.

See also

entity_entity_view_get_content_types()

File

ctools/content_types/entity_view.inc, line 54

Code

function entity_entity_view_content_type_edit_form($form, &$form_state) {
  $conf = $form_state['conf'];
  $entity_type = $form_state['subtype_name'];
  $entity_info = entity_get_info($entity_type);
  $options = array();
  if (!empty($entity_info['view modes'])) {
    foreach ($entity_info['view modes'] as $mode => $settings) {
      $options[$mode] = $settings['label'];
    }
  }
  if (count($options) > 1) {
    $form['view_mode'] = array(
      '#type' => 'select',
      '#options' => $options,
      '#title' => t('View mode'),
      '#default_value' => $conf['view_mode'],
    );
  }
  else {
    $form['view_mode_info'] = array(
      '#type' => 'item',
      '#title' => t('View mode'),
      '#description' => t('Only one view mode is available for this entity type.'),
      '#markup' => $options ? current($options) : t('Default'),
    );
    $form['view_mode'] = array(
      '#type' => 'value',
      '#value' => $options ? key($options) : 'default',
    );
  }
  return $form;
}