You are here

public function DateTimeFormInjectionTest::buildForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/datetime/tests/src/Kernel/DateTimeFormInjectionTest.php \Drupal\Tests\datetime\Kernel\DateTimeFormInjectionTest::buildForm()
  2. 10 core/modules/datetime/tests/src/Kernel/DateTimeFormInjectionTest.php \Drupal\Tests\datetime\Kernel\DateTimeFormInjectionTest::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

core/modules/datetime/tests/src/Kernel/DateTimeFormInjectionTest.php, line 66

Class

DateTimeFormInjectionTest
Tests serializing a form with an injected datetime instance.

Namespace

Drupal\Tests\datetime\Kernel

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['datelist_element'] = [
    '#title' => 'datelist test',
    '#type' => 'datelist',
    '#default_value' => new DrupalDateTime('2000-01-01 00:00:00'),
    '#date_part_order' => [
      'month',
      'day',
      'year',
      'hour',
      'minute',
      'ampm',
    ],
    '#date_text_parts' => [
      'year',
    ],
    '#date_year_range' => '2010:2020',
    '#date_increment' => 15,
  ];
  $form['#process'][] = [
    $this,
    'process',
  ];
  return $form;
}