-
Notifications
You must be signed in to change notification settings - Fork 1
Datetime field
Loïc Antignac edited this page May 24, 2022
·
5 revisions
By default, datetime field only requests the following informations:
Attention, the type is not datetime but datetime-local because the W3C dropped support for type@datetime.
[
'slug' => 'opening_day_hour',
'type' => 'datetime-local',
'labels' => [
'label' => 'opening_day_hour_label',
'help' => 'opening_day_hour_help',
],
],
The labels
key contains the keys for retrieving the labels from the labels
array at the root of the entity declaration. Eg:
$declarations[] = [
'entity' => 'Webaxones\Core\Option\SettingGroup',
'labels' => [
'opening_day_hour_label' => __( 'Opening day/hour', 'webaxones-content' ),
'opening_day_hour_help' => __( 'Opening day/hour of the company', 'webaxones-content' ),
],
But it is also possible to format the datetime field with an additional key called args
which takes an array of the optional arguments that an HTML 5 input type datetime-local can support.
Example:
[
'slug' => 'opening_day_hour',
'type' => 'datetime-local',
'labels' => [
'label' => 'opening_day_hour_label',
'help' => 'opening_day_hour_help',
],
'args' => [
'value' => '2024-06-12T19:30',
'min' => '2024-06-07T00:00',
'max' => '2024-06-14T00:00',
'className' => 'my-custom-class-name',
],
],
This control displays a date selector on click.