Editor 2, empty datetime issue ('Invalid date')
Editor 2, empty datetime issue ('Invalid date')
stephanb
Posts: 36Questions: 11Answers: 0
Just updated my codebase to Editor 2 and I noticed that it doesn't like empty datetime fields even in fields that don't change.
Look at this example: http://live.datatables.net/tebebuzo/13/edit
If you change the "Need by date" for "Package 2" to something else, the empty date field in the same row triggers the following form submission:
data[235][3]: 0
data[235][6]: 2021-04-21
data[235][7]: Invalid date
action: edit
How can I keep the 'Invalid date' from happening?
This question has accepted answers - jump to:
Answers
I noticed that when you click on "New Package", the modal also initializes with 'Invalid Date'
I had the similar issues in v1.9, I've written my own plugin for datetime fields now.
I couldn't get your example to submit to be able to test, but if you try to render an empty date field with moment it returns 'Invalid date' or 'Invalid format'
Try checking if there is a date to render and set it to null if it is empty. I render like this.
I tried to get this to work but I still get the same error. Have a look here: http://live.datatables.net/tebebuzo/16/edit
You can see the HTTP POST info by firing up your browser development settings (F12) and then watching the Network traffic. Once you see the call to /packages, click on it and scroll to the bottom. You'll see what it's trying to send to the server.
Hi,
I'm afraid you've discovered a bug that we missed in development here. There isn't an external workaround, but if you are comfortable making a small change in the Editor source code, search for:
and replace with:
That will fix it and I'll include that in the Editor 2.0.2 patch release. If you prefer, let me know and I'll send over the updated file.
Thanks,
Allan
Thanks. It worked for me. I'll download a new bundle when you push the patch release out. Just let us know.
@allan Please let me know when you've updated the live environment with 2.0.2. I may have another bug for you, but I need to replicate it there first.
2.0.2 is probably a week or two away as 2.0.1 only just dropped this week. Are you able to describe the issue and I'll try to replicate it here.
Thanks,
Allan
Look at this: http://live.datatables.net/tebebuzo/19/edit
This isn't date related.
When I make a change and trigger a submit I see the data sent to the server.
I process it and send back the json. What I then see in the browser's dev console is this:
At that point the datatables table locks up.
This applies to the multi-field-edits new in Editor 2, but it also happens with the normal inline edit setup.
@allan have you had a chance to look at this stack trace yet?
Hi,
Apologies for having not been able to get back to you yesterday. I'm not able to reproduce the error you are seeing in the live page (due to the 404 on the submission), but the error you are getting relates to these lines in Editor:
Do you have SearchBuilder on your page and initialised in the table? It isn't there in the live example, and if you don't on your actual page, I'm not clear on how that could get getting triggered. Any chance of PM'ing me a link to your actual page?
Allan
Searching for that error yields this thread and this thread. See if they help.
Kevin
I am not using SearchBuilder but I had it in my bundle. Removing it from my bundle did make the error go away. Unfortunately that doesn't help @allan to fix the underlying issue.
My site is not publicly accessible, so unfortunately I can't send him a link either.
The problem with the error
Uncaught TypeError: Cannot read property 'getDetails' of undefined
has been fixed and is in the nightly builds.Kevin
Hello,
it looks like the issue is back in version 2.0.5.
With 2.0.4 my code is working.
The version 2.0.5 set en empty date date value in the sql string to ''
@axel_tsys - Are you using the
ifEmpty()
formatter or anything else at the server-side to convert the empty string tonull
?Allan
No, I did not use any formatter at this point.
Until now it was not necessary.
But I have set this now and it is working as expected.
Thanks Alan