You are here

public function BatCalendarUnitReference::fieldSettingsForm in Booking and Availability Management Tools for Drupal 8

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 FieldItemBase::fieldSettingsForm

File

modules/bat_calendar_reference/src/Plugin/Field/FieldType/BatCalendarUnitReference.php, line 80
Contains \Drupal\bat_calendar_reference\Plugin\Field\FieldType\BatCalendarUnitReference.

Class

BatCalendarUnitReference
Plugin annotation @FieldType( id = "bat_calendar_unit_reference", label = @Translation("BAT Calendar Unit Reference"), description = @Translation("Display unit events information embedded from other fieldable content."), default_widget =…

Namespace

Drupal\bat_calendar_reference\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $element = [];
  $settings = $this
    ->getSettings();
  $element['referenceable_unit_types'] = [
    '#type' => 'checkboxes',
    '#title' => t('Unit types that can be referenced'),
    '#multiple' => TRUE,
    '#default_value' => $settings['referenceable_unit_types'],
    '#options' => array_map('\\Drupal\\Component\\Utility\\Html::escape', bat_unit_types_ids()),
    '#required' => TRUE,
  ];
  $element['referenceable_event_types'] = [
    '#type' => 'checkboxes',
    '#title' => t('Event types that can be referenced'),
    '#multiple' => TRUE,
    '#default_value' => $settings['referenceable_event_types'],
    '#options' => array_map('\\Drupal\\Component\\Utility\\Html::escape', bat_event_types_ids()),
    '#required' => TRUE,
  ];
  return $element;
}