function 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\KernelCode
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.
