public function SmartDateDefaultFormatter::settingsForm in Smart Date 8
Same name and namespace in other branches
- 8.2 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
File
- src/
Plugin/ Field/ FieldFormatter/ SmartDateDefaultFormatter.php, line 60
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']);
// 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,
];
return $form;
}