Forums

Setting today's date in date picker & opening redirect results in a new window

mike@webpred.uk 07 Nov, 2022
It's taken me quite a while to get my head round Chronoforms v7 compared to v5.

I have a basic form which submits a start date, end date and number of adults to a hotel's third party booking system. The data is redirected and the date formatting works.

However, there are two extra elements needed which I did manage to setup in v5 which I can't seem to setup in v7.
  1. I need to set the arrival date to "today's date"
  2. I need the redirection results to open in a new window
In v5, for today's date, I added some "custom code" in the "setup tab" ....

[strong]<?php
$form->data['arrival'] = date('Y-m-d');[br] $form->data['departure'] = date('Y-m-d', strtotime ('+2 days'));[br]?>[/strong]

and in the HTML (render form) block "on submit" I added the following "form tag attachment" to open the results in a new window:

onSubmit="return validate();" target="_blank"

[br]Can anybody assist me with this please? I've spent quite a while trying to find a solution to these last two items.

Many thanks,
Mike
Eddi Bournell 09 Nov, 2022
You can use CF7-shortcodes to preset a formfield. There are a lot of these shortcodes,
look here https://www.chronoengine.com/forums/posts/t110058/shortcodes-cheatsheet.

Open the fields "Advances Settings" -> enable "Value & Placeholder" and put into the "Value"-Field one of these:
  1. Get the current UTC date in Y-m-d H:i:s format: {date:}
  2. Pass a desired date/time format using the PHP format strings: {date:H:i}
  3. Pass a date value to be formatted: {date:Y-m-d$(var:some_date_value_or_timestamp)}
  4. Set the timezone to the one used by your site {date/site:}
  5. Set a timezone {date/region/time_zone:format_string}
  6. Set a future date/time {date:format_string $+ xx days yy hours}
No php is used. But if you have to use php:

$now = date("m-d-y");
$this->data("arival",$now,true);

cheers Eddi
mjandrew 09 Nov, 2022
thank you Eddi. I was missing that cheatsheet. i now have the date search form setup with today’s date.
the only bit i’m missing now is opening the redirection results in a new window.
i can hack it in as an attribute in the admin form output file but I was to be able to do it within the component.
overall I’m happy but redirection in a new window would be the cherry on the cake.
cheers mke
You need to login to be able to post a reply.