Buy Now
Sign in

Calendar or Date Field with automatic-dynamic First Day of Month

itadminguy , August 06 2018
itadminguy 31
August 06 2018 #379479
I am creating a billing invoice form for subcontractors. I want to make it as idiot proof as possible.Each invoice starts with the first day of the month, e.g., August Invoice (8-1-18), September Invoice (9-1-18) etc...

Does anybody know of a php code or new CF6 shortcode that can fix the date of the month?

I found this for the short code in cf6 but not sure it can be used to fix the first day of a month.
Or perhaps a php code On Load or On Submit can be used to fix the first day of the month for either Calendar Field or a Text Field (that simply places the date in the field)?
For example in CF5, I had a PHP code that would add ten days to a date as follows:

$d = new DateTime('10 days');
if ( !isset($form->data['date_field']) || !$form->data['date_field'] ) {$form->data['date_field'] =$d->format("Y-m-d");}
If I can fix the date to day one of the current month, e.g. August 1st since we are in August, there may be one other problem.
The invoice will be finalized in the first few days of the next month (September). If I bring the form up with the "fixed" first day of the month (where it should be August 1), it will probably change to September 1st.
So maybe there is a way to open the form in August, the August 1st date will be shown, and that date is "froze in time" or otherwise disabled????

healyhatman 5.7
August 07 2018 #379487
Web developer at
I don't work for ChronoEngine but I do accept donations

You can now copy+paste code from forums
GreyHead 63.4
August 07 2018 #379488
Hi itadminguy,
To 'freeze' the date in an Edit form you can show it in an input set to readonly.
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much