function DateFormatEditForm::form

Same name and namespace in other branches
  1. 9 core/modules/system/src/Form/DateFormatEditForm.php \Drupal\system\Form\DateFormatEditForm::form()
  2. 10 core/modules/system/src/Form/DateFormatEditForm.php \Drupal\system\Form\DateFormatEditForm::form()
  3. 11.x core/modules/system/src/Form/DateFormatEditForm.php \Drupal\system\Form\DateFormatEditForm::form()

Overrides DateFormatFormBase::form

File

core/modules/system/src/Form/DateFormatEditForm.php, line 17

Class

DateFormatEditForm
Provides a form for editing a date format.

Namespace

Drupal\system\Form

Code

public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);
    $now = t('Displayed as %date', [
        '%date' => $this->dateFormatter
            ->format(REQUEST_TIME, $this->entity
            ->id()),
    ]);
    $form['date_format_pattern']['#field_suffix'] = ' <small data-drupal-date-formatter="preview">' . $now . '</small>';
    $form['date_format_pattern']['#default_value'] = $this->entity
        ->getPattern();
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.