This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
Alter the datepicker options before they are converted to javascript.
Usage
add_filter( 'frm_date_field_options', 'my_custom_function', 20, 2 );
Parameters
- $date_options (array)
- $args (array)
- $args['field_id'] (string) - The HTML id for this field
- $args['options'] (array) - The settings for this field
Examples
Blackout dynamic dates
This example will Blackout the New Years day when the Datepicker Options plugin is used.
add_filter( 'frm_date_field_options', 'add_blackout_dates', 30, 2 );
function add_blackout_dates( $js_options, $extra ) {
if ( $extra['field_id'] === 'field_jtumj' ) { // Replace jtumj with your field key
$js_options['formidable_dates']['datesDisabled'][] = date( 'Y-m-d', strtotime( 'first day of january' ) );
}
return $js_options;
}
Hide month and year selectors
By default, the month and year are displayed in dropdown lists. By using this code, it will allow you to show the month and year in the calendar display header and have users select dates by using the next/previous buttons.
add_filter( 'frm_date_field_options', 'hide_month_and_year', 30, 2 );
function hide_month_and_year( $js_options, $extra ) {
if ( $extra['field_id'] === 'field_jtumj' ) { // Replace jtumj with your field key
$js_options['options']['changeMonth'] = false;
$js_options['options']['changeYear'] = false;
}
return $js_options;
}
Set the first day of the week for all forms
Use this code example to set the first day of the week in the datepicker for all forms.
add_filter('frm_date_field_options', 'set_start_day_all' );
function set_start_day_all( $options ) {
$options['options']['firstDay'] = 3;
return $options;
}
Set the first day of the week for a specific field
Use this code example to set the first day of the week in the datepicker for a specific date field key.
add_filter('frm_date_field_options', 'set_start_day', 10, 2);
function set_start_day( $options, $args ) {
$target_field_key = 'lyy3w'; // Replace lyy3w with the key of the date field.
if ( 'field_' . $target_field_key === $args['field_id'] ) {
$options['options']['firstDay'] = 3;
}
return $options;
}