I want to add single_datetime field to my custom API form.
I am trying to add the following code to my form, but not working properly
$form['dob'] = [
'#title' => 'Date of Birth',
'#type' => 'date',
'#attributes' => [
'data-hour-format' => '24h',
'data-allow-times' => '5',
'data-first-day' => '0',
'data-disable-days' => [],
'data-inline' => '0',
'data-datetimepicker-theme' => 'default',
'data-single-date-time' => 'datetime',
],
];
Please guide me , how to apply ?
Comments
Comment #2
selvakumar commentedI found the solution
$form['dob'] = [
'#title' => 'Date of Birth',
'#type' => 'textfield',
'#time' => TRUE,
'#weight' => -10,
'#attributes' => [
'data-hour-format' => '24h',
'data-allow-times' => '5',
'data-first-day' => '0',
'data-disable-days' => [],
'data-inline' => '0',
'data-datetimepicker-theme' => 'default',
'data-single-date-time' => 'datetime',
],
];
$form['#attached']['library'][] = 'single_datetime/datetimepicker';
$form['#attributes']['autocomplete'] = 'off';
$form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
];
Comment #3
valicExcellent example.
Will make addition to documentation.
Comment #4
valicUpdate README
Comment #5
djmanas commentedAny more information? how to change format, etc? I am lost after change to drupal 8...
Comment #8
valicupdated docs, and added some examples inside the readme file
https://github.com/Vallic/single_datetime/blob/8.x-1.x/README.md
Also added few static functions with default attributes for examples, and easier c/p integration of default widget for non-dev people
@djamanas, if you have some additional support questions, please open a new issue.
Comment #9
valicReleased in 1.7