Skip to content

how to set default for text_date field? #1245

@gyrus

Description

@gyrus

I have the following field definition for a front-end form:

$cmb->add_field( array(
	'name'        => 'Date',
	'id'          => 'date',
	'type'        => 'text_date',
	'date_format' => 'j/n/Y',
	'default'     => date( 'j/n/Y' ),
	'attributes' => array(
		'required' => 'required',
		'data-datepicker' => json_encode( array(
			'defaultDate' => null
		)),
	),
	'classes'    => array( 'required' ),
) );

Neither the 'default' param or the jQuery UI 'defaultDate' param seem to pass anything through ('null' is supposed to default to today: https://api.jqueryui.com/datepicker/#option-defaultDate).

The datepicker works fine, inserts in the right format. And if I just change the type to 'text', the default date appears OK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions