function DateTimeFormInjectionTest::buildForm

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

Overrides FormInterface::buildForm

File

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

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;
}

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