You are here

function ds_field_formatter_third_party_settings_form in Display Suite 8.2

Same name and namespace in other branches
  1. 8.4 ds.module \ds_field_formatter_third_party_settings_form()
  2. 8.3 ds.module \ds_field_formatter_third_party_settings_form()

Implements hook_field_formatter_third_party_settings_form().

File

./ds.module, line 809
Display Suite core functions.

Code

function ds_field_formatter_third_party_settings_form(FormatterInterface $plugin, FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) {
  $element = array();
  $field_info = $field_definition
    ->getFieldStorageDefinition();
  if (!empty($field_info) && $field_info
    ->getCardinality() != 1) {
    $name = $field_info
      ->getName();
    $settings = $form_state
      ->get('plugin_settings');
    $element['ds_limit'] = array(
      '#type' => 'textfield',
      '#title' => t('UI limit'),
      '#size' => 2,
      '#description' => t("Enter a number to limit the number of items or 'delta' to print a specific delta (usually configured in views or found in entity->ds_delta). Leave empty to display them all. Note that depending on the formatter settings, this option might not always work."),
      '#default_value' => !empty($settings[$name]['ds_limit']) ? $settings[$name]['ds_limit'] : '',
    );
  }
  if (\Drupal::config('ds.settings')
    ->get('field_template')) {
    $context = array(
      'instance' => $field_definition,
      'formatter' => $plugin,
    );
    ds_field_template_settings_form($element, $form_state, $context);
  }
  return $element;
}