public function DateTimeTimeAgoFormatter::settingsForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeTimeAgoFormatter::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 FormatterBase::settingsForm
File
- core/
modules/ datetime/ src/ Plugin/ Field/ FieldFormatter/ DateTimeTimeAgoFormatter.php, line 132 - Contains \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeTimeAgoFormatter.
Class
- DateTimeTimeAgoFormatter
- Plugin implementation of the 'Time ago' formatter for 'datetime' fields.
Namespace
Drupal\datetime\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
$form['future_format'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Future format'),
'#default_value' => $this
->getSetting('future_format'),
'#description' => $this
->t('Use <em>@interval</em> where you want the formatted interval text to appear.'),
);
$form['past_format'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Past format'),
'#default_value' => $this
->getSetting('past_format'),
'#description' => $this
->t('Use <em>@interval</em> where you want the formatted interval text to appear.'),
);
$form['granularity'] = array(
'#type' => 'number',
'#title' => $this
->t('Granularity'),
'#default_value' => $this
->getSetting('granularity'),
'#description' => $this
->t('How many time units should be shown in the formatted output.'),
);
return $form;
}