Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\FieldInstanceEditForm to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.
array $form: The form where the settings form is being included in.
array $form_state: An associative array containing the current state of the form.
array The form elements for the formatter settings.
Overrides FormatterBase::settingsForm
public function settingsForm(array $form, array &$form_state) {
$element = array();
$time = new DrupalDateTime();
$format_types = system_get_date_formats();
if (!empty($format_types)) {
foreach ($format_types as $type => $type_info) {
$options[$type] = $type_info['name'] . ' (' . format_date($time
->format('U'), $type) . ')';
}
}
$elements['format_type'] = array(
'#type' => 'select',
'#title' => t('Date format'),
'#description' => t("Choose a format for displaying the date. Be sure to set a format appropriate for the field, i.e. omitting time for a field that only has a date."),
'#options' => $options,
'#default_value' => $this
->getSetting('format_type'),
);
return $elements;
}