You are here

public function DateRecurItem::fieldSettingsForm in Recurring Dates Field 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldType/DateRecurItem.php \Drupal\date_recur\Plugin\Field\FieldType\DateRecurItem::fieldSettingsForm()
  2. 3.x src/Plugin/Field/FieldType/DateRecurItem.php \Drupal\date_recur\Plugin\Field\FieldType\DateRecurItem::fieldSettingsForm()
  3. 3.0.x src/Plugin/Field/FieldType/DateRecurItem.php \Drupal\date_recur\Plugin\Field\FieldType\DateRecurItem::fieldSettingsForm()
  4. 3.1.x src/Plugin/Field/FieldType/DateRecurItem.php \Drupal\date_recur\Plugin\Field\FieldType\DateRecurItem::fieldSettingsForm()

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

src/Plugin/Field/FieldType/DateRecurItem.php, line 130

Class

DateRecurItem
Plugin implementation of the 'date_recur' field type.

Namespace

Drupal\date_recur\Plugin\Field\FieldType

Code

public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::fieldSettingsForm($form, $form_state);
  $options = [];
  for ($i = 1; $i < 6; $i++) {
    $options['P' . $i . 'Y'] = $this
      ->formatPlural($i, '@count year', '@count years', [
      '@count' => $i,
    ]);
  }
  $element['precreate'] = [
    '#type' => 'select',
    '#title' => t('Precreate occurrences'),
    '#description' => t('For infinitely repeating dates, precreate occurrences for this amount of time in the views cache table.'),
    '#options' => $options,
    '#default_value' => $this
      ->getSetting('precreate'),
  ];
  return $element;
}