Default value in date field

happy new year!
It’s been a while but I’m using a form which has a date as a field but I want it to be optional. I’ve removed any required flags, but the record is not saved if there is no value on the form in the date field. Is there another way to specify a default value for a date which is null or empty?

Thanks,Rick

First check if using an application like phpMyAdmin or similar, you can insert into your database without the date, if you can, then you can make it conditional rather than empty or null when doing your insert. Ie. If field empty then do not even post a value, else if it has something inserted then send the value.
As far as I can recall MySQL will allow date, datetime, timestamp, time, and year field types to all be set to NULL, as long as your table structure has been created that way

Have you tried setting wappler debugging on for server connect and checking for server errors.That may give you the reason why the save is failing

I am just looking at this issue

The explanation page shows the recommended way to use a datetime value is to ADD it AS A COMPONENT to the APP?

I can’t simply go to the FORM FIELD directly and Choose Options there?

  <label for="inp_regtime">Zeit</label>
  <input type="date" class="form-control" id="inp_regtime" name="regtime" aria-describedby="inp_regtime_help" placeholder="Enter Regtime" dmx-on:input="">

go to the dynamic attributes on the form input and select Input->Value and set it to the date and time component

I have looked closely at this – where I have to ADD the DATETIME COMPONENT to the APP

But the document is vague about how I BIND what I now have is VAR 1 set to update UTC every 1 minute.

When I select the Time field I want to Bind to this Time component I see DATA BINDINGS

But where does this come from?

And am I supposed to go to something like DYNAMIC EVENTS – make a Dynamic event
and Then SELECT ACTION and add something?

The Dynamic Event Properties Selector does not show the ADDED Component and VAR 1 as an option.

This just not covered thoroughly enough.

So I must ask for help from people who have been down this trail before.

Thank you, so much!

Do you mean DYNAMIC EVENTS?

No, dynamic attributes and bind the form input to the data time component

Sorry only saw this after answering on the other post about sessions, I’m going s different way to brian however both would or should work either way.

Brilliant! Now I will check on PSWEB - I got distracted by seeing this question recently posted.

I do get this error –

formElement.js:97 The specified value "2020-01-02T16:26:00Z" does not conform to the required format, "yyyy-MM-dd".

So I have to now take this into the Data Formatter to transform it before it is submitted?

Or go play with my mysql input type?

1 Like

Surprised that doesn’t work out of the box, maybe it is the T that confuses it. Either way, just use FormatDate to set the format

Edit. Just realised, have you set he input type to date to datetime?
Change it to text and it should work as it is

1 Like