You are here

function ds_field_settings_form in Display Suite 7.2

Same name and namespace in other branches
  1. 8.4 includes/field_ui.inc \ds_field_settings_form()
  2. 8.2 includes/field_ui.inc \ds_field_settings_form()
  3. 8.3 includes/field_ui.inc \ds_field_settings_form()
  4. 7 ds.field_ui.inc \ds_field_settings_form()

Creates a form for Display Suite fields. .

Parameters

$field: The field definition.

Return value

$form A form definition.

1 call to ds_field_settings_form()
_ds_field_ui_fields in includes/ds.field_ui.inc
Add the fields to the Field UI form.

File

includes/ds.field_ui.inc, line 1139
Field UI functions for Display Suite.

Code

function ds_field_settings_form($field, &$form_state, $entity_form, $view_mode) {
  $form = module_invoke($field['module'], 'ds_field_settings_form', $field);

  // Add field template settings to every field if enabled.
  if (module_exists('ds_extras') && variable_get('ds_extras_field_template', FALSE)) {
    $context = array(
      'instance' => array(
        'entity_type' => $field['entity_type'],
        'bundle' => $field['bundle'],
        'field_name' => $field['name'],
      ),
      'view_mode' => $field['view_mode'],
    );

    // Load the formatter settings form
    module_load_include('inc', 'ds_extras', 'includes/ds_extras.admin');

    // Protect against empty $form.
    if (!is_array($form)) {
      $form = array();
    }
    if (!in_array($field['field_type'], array(
      DS_FIELD_TYPE_IGNORE,
      DS_FIELD_TYPE_PREPROCESS,
    ))) {
      ds_extras_field_template_settings_form($form, $form_state, $context);
    }
    else {
      $form['#markup'] = t('This field does not support Field templates.');
    }
  }
  $formatter_name = $form_state['complete form']['fields'][$field['name']]['format']['type']['#value'];

  // Allow other modules to alter the formatter settings form.
  $context = array(
    'ds' => TRUE,
    'formatter' => $formatter_name,
    'field' => $field,
    'instance' => array(
      'label' => $field['title'],
      'bundle' => $field['bundle'],
      'entity_type' => $field['entity_type'],
      'display' => array(
        'default' => array(
          'settings' => isset($field['formatter_settings']) ? $field['formatter_settings'] : array(),
        ),
      ),
    ),
    'view_mode' => $view_mode,
    'form' => $entity_form,
    'form_state' => $form_state,
  );
  drupal_alter('field_formatter_settings_form', $form, $context);
  return $form;
}