You are here

public function ViewfieldItem::fieldSettingsForm in Viewfield 8.3

Returns a form for the field-level settings.

Invoked from \Drupal\field_ui\Form\FieldConfigEditForm to allow administrators to configure field-level settings.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The form state of the (entire) configuration form.

Return value

array The form definition for the field settings.

Overrides EntityReferenceItem::fieldSettingsForm

File

src/Plugin/Field/FieldType/ViewfieldItem.php, line 112

Class

ViewfieldItem
Plugin implementation of the 'viewfield' field type.

Namespace

Drupal\viewfield\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $form = [];
  $form['force_default'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Always use default value'),
    '#default_value' => $this
      ->getSetting('force_default'),
    '#description' => $this
      ->t('Hides this field in entity edit forms and enforces the configured default value for all entities in the bundle, making it unnecessary to assign values individually to each one.<br>If this is checked, you must provide a default value.'),
  ];
  $form['allowed_views'] = [
    '#type' => 'checkboxes',
    '#options' => $this
      ->getViewOptions(FALSE),
    '#title' => $this
      ->t('Allowed views'),
    '#default_value' => $this
      ->getSetting('allowed_views'),
    '#description' => $this
      ->t('Views available for content authors. Leave empty to allow all.'),
  ];
  $form['allowed_display_types'] = [
    '#type' => 'checkboxes',
    '#options' => $this
      ->getDisplayTypeOptions(),
    '#title' => $this
      ->t('Allowed display types'),
    '#default_value' => $this
      ->getSetting('allowed_display_types'),
    '#description' => $this
      ->t('Display types available for content authors. Leave empty to allow all.'),
  ];
  $form['#element_validate'][] = [
    get_called_class(),
    'fieldSettingsFormValidate',
  ];
  return $form;
}