Date Picker

The date-picker lets you add a field for selecting date.

Mode set to single

Date Picker

Mode set to range

Date Picker

Parameters

Here are the parameters in adding button-set.

id
string | required

a unique slug-like string to use as an id and also as index in saving data in database.

label
string | optional

the label of the field.

description
string | optional

the description of the field and display under the label.

section
string | requiredl

the section where the field will be displayed.

default
string | optional

the default value of the field.

priority
integer | optional

determines the order of fields in section.

placeholder
string | optional

display placeholder in the field.

mode
string | optional :: single | range

set the type of mode single or range.

enable_time
boolean | optional | default : false

allows to add time in calendar.

Notes

1. The default value will be depending on the mode

  • if mode is set to single so the default value must be supplied string
  • if mode is set to range 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 to false the format will be Y-m-d YEAR-MONTH-DATE
  • if enable_time is set to true the format will be Y-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');