Jump to content

Date Field - Default to today's date


Jee
 Share

Recommended Posts

Hi,

My form is set to save to a processwire page each time the form is submited but i'm having an issue with the date field and can't find the solution on the forums.

The datefield on my page template is set to use today's date as default and i display it on my site when the form was submited.

The date field doesn't display anything unless i go edit the page and save it.

I tried to add a hidden datefield on my form and relate it with the date field on my page but doesn't work either. 

Maybe the option (Default to today's date) was not created to save the value but just to display something.

 

Link to comment
Share on other sites

Hi Jee,

if empty, the inputfield set himself with the right value on the page save(). Doing something like this should work :

// set outputformatting to false
$page->of(false);
// set the date field to an empty string
$page->datenow = '';
// save the page, the date field should be updated
$page->save();
// set outputformatting to true
$page->of(true);

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...