Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Datetime-Local - not displayed after saving Topic is solved
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Datetime-Local - not displayed after saving
Hi,
Has anyone managed to setup a Datetime-Local object field so that its changed value is displayed again after saving the record?
Setup:
- An object of type: Input, Input Type : Datetime-Local
- db data type: datetime (or timestamp)
1. First enter a date/time: 2. Save the form
3. Result: The field reverts back to its original state: Looking at the db table, the datetime value has been correctly stored. But when I go back to the Browse Form and open that record again, the Datetime-Local field is still empty (respectively showing mm/dd/yyy...)
Am I missing something?
Has anyone managed to setup a Datetime-Local object field so that its changed value is displayed again after saving the record?
Setup:
- An object of type: Input, Input Type : Datetime-Local
- db data type: datetime (or timestamp)
1. First enter a date/time: 2. Save the form
3. Result: The field reverts back to its original state: Looking at the db table, the datetime value has been correctly stored. But when I go back to the Browse Form and open that record again, the Datetime-Local field is still empty (respectively showing mm/dd/yyy...)
Am I missing something?
You do not have the required permissions to view the files attached to this post.
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Datetime-Local - not displayed after saving
Hi,
I've tried to isolate the source of the problem by inspecting the datetime-local object f.objects in nuBuildEditObjects();
It's value is correctly stored as:
value = "2018-12-30 10:10:00"
But its format is empty:
format = "";
Consequently (this is what I think), no value is applied in addFormatting(); because its format is empty.
I've tried to isolate the source of the problem by inspecting the datetime-local object f.objects in nuBuildEditObjects();
It's value is correctly stored as:
value = "2018-12-30 10:10:00"
But its format is empty:
format = "";
Consequently (this is what I think), no value is applied in addFormatting(); because its format is empty.
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Datetime-Local - not displayed after saving
I worked out a fix. Can you check if it works for you too?
nuForm.js (624)
And the function to convert to datetime-local format:
nuForm.js (624)
Code: Select all
if(input_type != 'file'){
if(input_type == 'datetime-local'){ // added
var d = new Date(w.objects[i].value); // added
$('#' + id).val(toDatetimeLocal(d)) // added
}else if(input_type == 'button'){
$('#' + id).val(nuTranslate(w.objects[i].value))
}else{
$('#' + id).val(nuFORM.addFormatting(w.objects[i].value, w.objects[i].format));
}
}
And the function to convert to datetime-local format:
Code: Select all
function toDatetimeLocal(d) {
var
YYYY = d.getFullYear(),
MM = nuPad2(d.getMonth() + 1),
DD = nuPad2(d.getDate()),
HH = nuPad2(d.getHours()),
II = nuPad2(d.getMinutes()),
SS = nuPad2(d.getSeconds());
return YYYY + '-' + MM + '-' + DD + 'T' + HH + ':' + II; // + ':' + SS;
};
Re: Datetime-Local - not displayed after saving
toms,
I have made a change and uploaded it to Github.
I think it should work fine now.
Steven
I have made a change and uploaded it to Github.
I think it should work fine now.
Steven
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Datetime-Local - not displayed after saving
Steven,
It works like that but a warning is displayed when the value is "0000-00-00 00:00:00"
It works like that but a warning is displayed when the value is "0000-00-00 00:00:00"
You do not have the required permissions to view the files attached to this post.
Re: Datetime-Local - not displayed after saving
toms,
That was happening to me as well before the latest Github update.
But it works ok for me now.
Steven
That was happening to me as well before the latest Github update.
But it works ok for me now.
Steven
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Datetime-Local - not displayed after saving
Steven,
Don't you see a warning message in the console when no datetime value has been entered in the field? (tested with different nuBuilder instances)
Normally you should since the
Don't you see a warning message in the console when no datetime value has been entered in the field? (tested with different nuBuilder instances)
Normally you should since the
value "0000-00-00T00:00:00" does not conform to the required format.
Re: Datetime-Local - not displayed after saving
toms,
I originally tested it in the console using jQuery, to find out why it wasn't working.
That's why I have seen that message.
Its fixed though in nuBuilder now (from what I figured out using the console).
If you do something like $('#thedateandtime').val("0000-00-00T00:00:00"), in the console, you will still get the same message.
But that has nothing to do with nuBuilder.
When a nuBuilder Forte Form is opened a date/time field is now displayed and I see no message,
It loads the value properly now, which it didn't originally when you found the bug.
Steven
I originally tested it in the console using jQuery, to find out why it wasn't working.
That's why I have seen that message.
Its fixed though in nuBuilder now (from what I figured out using the console).
If you do something like $('#thedateandtime').val("0000-00-00T00:00:00"), in the console, you will still get the same message.
But that has nothing to do with nuBuilder.
When a nuBuilder Forte Form is opened a date/time field is now displayed and I see no message,
It loads the value properly now, which it didn't originally when you found the bug.
Steven
-
- Posts: 28
- Joined: Fri May 20, 2016 9:24 am
Re: Datetime-Local - not displayed after saving
why not use functions built into MySQL/MariaDB for this? I went this way and it's magnitudes of orders simpler.