public function SmartDateDefaultFormatter::settingsForm in Smart Date 8.2
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldFormatter/SmartDateDefaultFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDefaultFormatter::settingsForm()
- 3.x src/Plugin/Field/FieldFormatter/SmartDateDefaultFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDefaultFormatter::settingsForm()
- 3.0.x src/Plugin/Field/FieldFormatter/SmartDateDefaultFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDefaultFormatter::settingsForm()
- 3.1.x src/Plugin/Field/FieldFormatter/SmartDateDefaultFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDefaultFormatter::settingsForm()
- 3.2.x src/Plugin/Field/FieldFormatter/SmartDateDefaultFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDefaultFormatter::settingsForm()
- 3.3.x src/Plugin/Field/FieldFormatter/SmartDateDefaultFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDefaultFormatter::settingsForm()
- 3.4.x src/Plugin/Field/FieldFormatter/SmartDateDefaultFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDefaultFormatter::settingsForm()
Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form elements for the formatter settings.
Overrides DateTimeDefaultFormatter::settingsForm
2 calls to SmartDateDefaultFormatter::settingsForm()
- SmartDateDurationFormatter::settingsForm in src/
Plugin/ Field/ FieldFormatter/ SmartDateDurationFormatter.php - Returns a form to configure settings for the formatter.
- SmartDateRecurrenceFormatter::settingsForm in modules/
smart_date_recur/ src/ Plugin/ Field/ FieldFormatter/ SmartDateRecurrenceFormatter.php - Returns a form to configure settings for the formatter.
2 methods override SmartDateDefaultFormatter::settingsForm()
- SmartDateDurationFormatter::settingsForm in src/
Plugin/ Field/ FieldFormatter/ SmartDateDurationFormatter.php - Returns a form to configure settings for the formatter.
- SmartDateRecurrenceFormatter::settingsForm in modules/
smart_date_recur/ src/ Plugin/ Field/ FieldFormatter/ SmartDateRecurrenceFormatter.php - Returns a form to configure settings for the formatter.
File
- src/
Plugin/ Field/ FieldFormatter/ SmartDateDefaultFormatter.php, line 43
Class
- SmartDateDefaultFormatter
- Plugin implementation of the 'Default' formatter for 'smartdate' fields.
Namespace
Drupal\smart_date\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
// Use the upstream settings form, which gives us a control to override the
// timezone.
$form = parent::settingsForm($form, $form_state);
// Remove the upstream format_type control, since we want the user to choose
// a Smart Date Format instead.
unset($form['format_type']);
// Change the description of the timezone_override element.
if (isset($form['timezone_override'])) {
$form['timezone_override']['#description'] = $this
->t('The time zone selected here will be used unless overridden on an individual date.');
}
// Ask the user to choose a Smart Date Format.
$smartDateFormatOptions = $this
->getAvailableSmartDateFormatOptions();
$form['format'] = [
'#type' => 'select',
'#title' => $this
->t('Smart Date Format'),
'#description' => $this
->t('Choose which display configuration to use.'),
'#default_value' => $this
->getSetting('format'),
'#options' => $smartDateFormatOptions,
];
// Provide an option to force a chronological display.
$form['force_chronological'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Force chronogical'),
'#description' => $this
->t('Override any manual sorting or other differences.'),
'#default_value' => $this
->getSetting('force_chronological'),
];
return $form;
}