Newer
Older
Alex Pott
committed
<?php
namespace Drupal\system\Form;
Dries Buytaert
committed
use Drupal\Core\Form\FormStateInterface;
Alex Pott
committed
/**
Alex Pott
committed
* Provides a form for editing a date format.
*
* @internal
Alex Pott
committed
*/
Alex Pott
committed
class DateFormatEditForm extends DateFormatFormBase {
Alex Pott
committed
/**
Alex Pott
committed
* {@inheritdoc}
Alex Pott
committed
*/
Dries Buytaert
committed
public function form(array $form, FormStateInterface $form_state) {
Alex Pott
committed
$form = parent::form($form, $form_state);
Alex Pott
committed
$now = t('Displayed as %date', ['%date' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id())]);
Alex Pott
committed
$form['date_format_pattern']['#field_suffix'] = ' <small data-drupal-date-formatter="preview">' . $now . '</small>';
$form['date_format_pattern']['#default_value'] = $this->entity->getPattern();
Alex Pott
committed
Alex Pott
committed
return $form;
Alex Pott
committed
}
/**
* {@inheritdoc}
*/
Dries Buytaert
committed
protected function actions(array $form, FormStateInterface $form_state) {
Alex Pott
committed
$actions = parent::actions($form, $form_state);
$actions['submit']['#value'] = t('Save format');
unset($actions['delete']);
return $actions;