Skip to content

Control: Datepicker

Ale Mostajo edited this page Apr 29, 2020 · 1 revision

Control used as a field type to display a jQuery UI Datepicker.

Usage

class Post extends Model
{
    // Class properties and methods...

    protected function init()
    {
        $this->metaboxes = [
            'metabox_id' => [
                'tabs' => [
                    'tab_id' => [
                        'fields' => [

                            'date' => [
                                'type' => 'datepicker',
                                'title' => __( 'Date' ),
                            ],

                            'custom_date' => [
                                'type' => 'datepicker',
                                'title' => __( 'Another date' ),
                                'control' => [
                                    'attributes' => [
                                        'data-date-format' => 'mm/dd/yy',
                                        'data-show-button-panel' => 1,
                                        'data-show-other-months' => 1,
                                        'data-select-other-months' => 1,
                                        'data-change-month' => 1,
                                        'data-change-year' => 1,
                                    ],
                                ],
                            ],

                            // Other fields...
                        ],
                    ],
                ],
            ],
        ];
    }
}

Control options

Control Data type Description
autocomplete bool HTML autocomplete option. Default: false
attributes array HTML attributes listed as an array. jQuery UI Datepicker options can be set as a data attribute.