Buy Now
Sign in

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

itadminguy , August 06 at 19:05
I
itadminguy
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.
{date:Y-m-d$tomorrow}
https://www.chronoengine.com/forums/posts/t103504/cf6-calendar-set-dynamic-start-date?keywords=php%20calendar
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:
<?php ​
​​
​ $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
{date:Y-m-01}
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
GreyHead
Hi itadminguy,
To 'freeze' the date in an Edit form you can show it in an input set to readonly.
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much