Date Input Control
Date Input Control
I have the following Editor Field code:
// Termination Date
{
label: "Termination Date:",
name: "userNotVaildDate",
type: "date",
def: function () { return new Date(); },
dateFormat: $.datepicker.ISO_8601
}
The datepicker field provides the current date when the database value for the 'userNotVaildDate' field is null; I need it to provide the null value. Any help is appreciated.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
Interesting one. The
def
function is only run if the value isundefined
.null
values should not trigger the default value to be used.In Editor, you will find the following code:
Could you add
console.log( field.name(), val );
just after those lines to check what the value is (i.e. if it is undefined). Could you also try using the DataTables nightly, if you aren't already: http://datatables.net/download/#DataTables ).Thanks,
Allan
The value in the database was not null instead was '0000-00-00'. I made them a null value by default and the datepicker field provides a blank field. It does however revert back to the '0000-00-00' value when saving the null from the form using the code. I am using PHP 5.2.0, the field is a DATE type and the default value is null.
I tried the console log request as follows:
No value appeared in the Firebug console.
Thanks for any help.
Ah, if you re using PHP 5.2 then you must also be using the old (and now unsupported) PHP libraries for Editor I guess? Or have you got your own custom libraries. Either way, I would suggest that what needs to be done is if the value come the client-side is an empty string (I'm presuming it is?) then set the value as
null
into the database. A setFormatter could be used to do that in the Editor PHP libraries (although I'm not sure about the old 5.2 compatible libraries).Allan
I found an easy solution by changing the database field to varchar data type, working so far.