How do I set the first day of the week in an inline date field?

By: Paul Yates | Asked: 11/21/2022
ForumsCategory: Code HelpHow do I set the first day of the week in an inline date field?
Paul Yates asked 1 year ago
I've tried this code but not sure why it's not working:  
add_filter('frm_date_field_js', 'change_start_day');
function change_start_day($args){
if($args['field_id'] == 10){
$args['firstDay'] = 1;
}
return $args;
}
3 Answers
Rob LeVineRob LeVine answered 1 year ago
I'm not sure where you got that code, but it ain't ever gonna work :). Substitute the field KEY of the date field in where you see 'rqaj9'.  
add_filter('frm_date_field_js', 'change_start_day');
function change_start_day($field_key) { /* the examples use "field_id" but it's the key */
	if ($field_key == 'field_rqaj9') {
		echo ',firstDay: 1';
	}
}
Paul Yates answered 1 year ago
xD thanks. That works but doesn't seem to work at all with the advanced datepicker options. I'm guessing it's just overwriting all the options?
Rob LeVineRob LeVine replied 1 year ago

It appends a "parameter" javascript that is the datepicker. It should be used for all parameters that aren't covered by the Formidalbe datepicker addon as long as you have the correct syntax.

Paul Yates answered 1 year ago
Yeah I suspect a syntax error caused by it being an inline date field. I used this instead and it works:
add_filter( 'frm_date_field_options', 'add_blackout_dates', 30, 2 );
function add_blackout_dates( $js_options, $extra ) {
	if ( $extra['field_id'] === 'field_2u7es' ) {
		$js_options['options']['firstDay'] = 1;
	}
	return $js_options;
}

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right