Forums

Save date time empty

jonnyblog1976 25 Apr, 2018
Hi,
my simple form (only one calendar field) load record 1 of a table and with a submit button it save on the same record. it work perfectly,
but if i delete the time and i left empty it save on the table the actual time . iI would like to save an empty value.
here some screeshot:








thanks in advance
healyhatman 26 Apr, 2018
try not calling the field date or time. And make sure your table isn't set to give that date field a default.
jonnyblog1976 27 Apr, 2018
Hi, thank you for the reply

i chande the name but it doesn' t work.





i also tried to flag NULL but it save the actual time.
jonnyblog1976 27 Apr, 2018
i also tried a custom code before the save data:

if(empty($this->data["t1me"])){
unset($this->data["t1me"]);
}
same result
healyhatman 27 Apr, 2018
Try adding the field to the list of fields in Override on Update and override on Insert maybe
healyhatman 27 Apr, 2018
is it saving the current time, or showing the current time when you load the form
healyhatman 27 Apr, 2018
Also, put a debug after your save data and paste it here to show what's being put in the save_data action
jonnyblog1976 27 Apr, 2018
it load the db value, if i modify it save the new time and reload it. if i delete and leave the field empty it save the current time
jonnyblog1976 28 Apr, 2018
Sorry the print was wrong
here the correct one:

thanks
healyhatman 28 Apr, 2018
Yeah it seems that the calendar field puts the current date / time into the hidden field when you delete the text. You'd probably have to put a custom javascript function in and set the onchange event to check if the input is empty and use that to wipe the data field.
jonnyblog1976 29 Apr, 2018
Hi, hatman , i tried different approaches but seem it depend from the datapicker code...
I also tried the php code suggest by Max

if(empty($this->data["t1me"])){unset($this->data["t1me"]);}

if the datapicker find the field empty , it set the actual date...
I would not give up to use a simple text field and handwrite the date ...
healyhatman 29 Apr, 2018
The PHP code suggested by Max won't work, you'll need to do what I said because even though the text field is empty the hidden field that actually stores the data is what gets sent when you submit a calendar field, and it gets set to the current date when you clear the text field.
jonnyblog1976 29 Apr, 2018
Max do you have any tips for the datapicker (calendar field) ?
jonnyblog1976 29 Apr, 2018
ok hat , but how i reach this hidden field? its name?
healyhatman 29 Apr, 2018
Right click field, "inspect". The hidden field is right after your visible date field.
jonnyblog1976 29 Apr, 2018
sorry, you could tell me where to look:

GreyHead 29 Apr, 2018
Hi jonnyblog1976,

See the line: <input type="hidden" name="t1me" value="08:51">

Bob
This topic is locked and no more replies can be posted.