Date Picker
The date-picker
lets you add a field for selecting date.
Mode set to single

Mode set to range

Parameters
Here are the parameters in adding button-set
.
a unique slug-like string to use as an id and also as index in saving data in database.
the label of the field.
the description of the field and display under the label.
the section where the field will be displayed.
the default value of the field.
determines the order of fields in section.
display placeholder in the field.
set the type of mode single or range.
allows to add time in calendar.
Notes
1. The default value will be depending on the mode
- if
mode
is set tosingle
so the default value must be supplied string - if
mode
is set torange
so the default value must be supplied array with two date the START DATE and END DATE
2. The date format in default value also depending on enable_time
.
- if
enable_time
is set tofalse
the format will beY-m-d
YEAR-MONTH-DATE - if
enable_time
is set totrue
the format will beY-m-d H:i
YEAR-MONTH-DATE HOUR-MINUTE
Example
Yano::field( 'date-picker', [
'id' => 'datepickerdb1',
'label' => 'Set The Date',
'description' => 'Please add date you want.',
'section' => 'section_id',
'default' => '2020-05-30',
'priority' => 1,
'placeholder' => 'Date',
'mode' => 'single',
] );
Example with mode
: range
and enable_time
: true
.
Yano::field( 'date-picker', [
'id' => 'datepickerdb1',
'label' => 'Set The Date',
'description' => 'Please add date you want.',
'section' => 'section_id',
'default' => ['2020-01-05', '2020-01-10'],
'mode' => 'range',
'priority' => 1,
'enable_time' => true,
'placeholder' => 'Date',
] );
Usage
The yano_get_special_values()
function is recommended to retrieve data.
// Return a array
$date = yano_get_special_values('datepickerdb1');