DateFormatEditForm::form

public DateFormatEditForm::form(array $form, FormStateInterface $form_state)

Gets the actual form array to be built.

Overrides DateFormatFormBase::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

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

Class

DateFormatEditForm
Provides a form for editing a date format.

Namespace

Drupal\system\Form

Code

1
2
3
4
5
6
7
8
9
public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
 
  $now = t('Displayed as %date', array('%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;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.