You are here

function ds_extras_ds_field_settings_form in Display Suite 7.2

Same name and namespace in other branches
  1. 7 modules/ds_extras/ds_extras.admin.inc \ds_extras_ds_field_settings_form()

Implements hook_ds_field_settings_form().

File

modules/ds_extras/includes/ds_extras.admin.inc, line 504
Display Suite Extras administrative functions.

Code

function ds_extras_ds_field_settings_form($field) {
  $form = array();

  // Switch field.
  if (variable_get('ds_extras_switch_field') && $field['name'] == 'ds_switch_field') {
    $entity_type = $field['entity_type'];
    $bundle = $field['bundle'];
    $view_mode = $field['view_mode'];
    $settings = isset($field['formatter_settings']['vms']) ? $field['formatter_settings']['vms'] : array();
    $view_modes = ds_entity_view_modes($entity_type);
    $form['info'] = array(
      '#markup' => t('Enter a label for the link for the view modes you want to switch to.<br />Leave empty to hide link. They will be localized.'),
    );
    foreach ($view_modes as $key => $value) {
      $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
      $visible = !empty($view_mode_settings[$key]['custom_settings']);
      if ($visible) {
        $form['vms'][$key] = array(
          '#type' => 'textfield',
          '#default_value' => isset($settings[$key]) ? $settings[$key] : '',
          '#size' => 20,
          '#title' => check_plain($value['label']),
        );
      }
    }
  }
  return $form;
}