public function SmartDateDefaultFormatter::settingsForm in Smart Date 3.2.x
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/SmartDateDefaultFormatter.php \Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDefaultFormatter::settingsForm()
- 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.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
3 calls to SmartDateDefaultFormatter::settingsForm()
- SmartDateDailyRangeFormatter::settingsForm in modules/
smart_date_recur/ src/ Plugin/ Field/ FieldFormatter/ SmartDateDailyRangeFormatter.php - Returns a form to configure settings for the formatter.
- 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.
3 methods override SmartDateDefaultFormatter::settingsForm()
- SmartDateDailyRangeFormatter::settingsForm in modules/
smart_date_recur/ src/ Plugin/ Field/ FieldFormatter/ SmartDateDailyRangeFormatter.php - Returns a form to configure settings for the formatter.
- 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 46
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 chronological'),
'#description' => $this
->t('Override any manual sorting or other differences.'),
'#default_value' => $this
->getSetting('force_chronological'),
];
// Provide an option to add spans around the date and time values.
$form['add_classes'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Add classes'),
'#description' => $this
->t('Add classed spans around the time and date values.'),
'#default_value' => $this
->getSetting('add_classes'),
];
// Provide an option to add spans around the date and time values.
$form['time_wrapper'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Add time wrapper'),
'#description' => $this
->t('Include an HTML5 time wrapper in the markup. Start and end dates will be individually wrapped.'),
'#default_value' => $this
->getSetting('time_wrapper'),
];
return $form;
}