function DatetimeElementFormTest::buildForm
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php \Drupal\KernelTests\Core\Datetime\DatetimeElementFormTest::buildForm()
- 10 core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php \Drupal\KernelTests\Core\Datetime\DatetimeElementFormTest::buildForm()
- 11.x core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php \Drupal\KernelTests\Core\Datetime\DatetimeElementFormTest::buildForm()
Overrides FormInterface::buildForm
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Datetime/ DatetimeElementFormTest.php, line 55
Class
- DatetimeElementFormTest
- Tests DatetimeElement functionality.
Namespace
Drupal\KernelTests\Core\DatetimeCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['datetime_element'] = [
'#title' => 'datelist test',
'#type' => 'datetime',
'#default_value' => new DrupalDateTime('2000-01-01 00:00:00'),
'#date_date_format' => 'Y-m-d',
'#date_time_format' => 'H:i:s',
'#date_date_element' => 'HTML Date',
'#date_time_element' => 'HTML Time',
'#date_increment' => 1,
'#date_date_callbacks' => [
[
$this,
'datetimecallback',
],
],
];
// Element without specifying the default value.
$form['simple_datetime_element'] = [
'#type' => 'datetime',
'#date_date_format' => 'Y-m-d',
'#date_time_format' => 'H:i:s',
'#date_date_element' => 'HTML Date',
'#date_time_element' => 'HTML Time',
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
];
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.