You are here

function content_content_field_content_type_edit_form in Content Construction Kit (CCK) 6.3

Same name and namespace in other branches
  1. 6.2 includes/panels/content_types/content_field.inc \content_content_field_content_type_edit_form()

Returns a settings form for the custom type.

File

includes/panels/content_types/content_field.inc, line 136
This file provides a CTools content type for fields.

Code

function content_content_field_content_type_edit_form(&$form, &$form_state) {
  $conf = $form_state['conf'];
  $form['label'] = array(
    '#type' => 'select',
    '#title' => t('Field label'),
    '#default_value' => isset($conf['label']) ? $conf['label'] : '',
    '#options' => array(
      'normal' => t('Block title'),
      'above' => t('Above'),
      'inline' => t('Inline'),
    ),
    '#description' => t('Configure how the label is going to be displayed. This option takes no effect when "Override title" option is enabled, the specified block title is displayed instead.'),
  );

  // Extract the field name from the panels content type subtype.
  $field_name = $form_state['subtype_name'];

  // Previous versions of CCK included the content type as part of the subtype.
  // This allows those to continue to sort of work.
  if (strpos($field_name, ':') !== FALSE) {
    list($content_type, $field_name) = explode(':', $field_name, 2);
  }

  // Get all the information about our field.
  $field = content_fields($field_name);

  // Get information about all the field types on the site.
  $field_types = _content_field_types();

  // Get the information about the type that our field is.
  $type_info = $field_types[$field['type']];

  // Put the possible formatters for our type into an array.
  $options = array();
  foreach ($type_info['formatters'] as $formatter_name => $formatter) {
    $options[$formatter_name] = $formatter['label'];
  }
  $form['formatter'] = array(
    '#type' => 'select',
    '#title' => t('Field formatter'),
    '#default_value' => isset($conf['formatter']) ? $conf['formatter'] : 'default',
    '#options' => $options,
    '#description' => t('Select a formatter.'),
    '#required' => TRUE,
  );
}