Datetime field not showing error message from server
Datetime field not showing error message from server
finsight-ak
Posts: 19Questions: 5Answers: 0
Hi! I'm running into an issue where I'm sending down an error message in the fieldErrors
array in json to a datetime field, but the only text displaying in the editor-datetime-error
div is 'Error'.
It's finding the correct field and setting an error, but the message doesn't seem to be inserted. Any ideas on what I might be doing wrong?
This discussion has been closed.
Answers
If you click outside the date field to hide the picker, do you see the error message below? Editor 1.6 introduced a new way to fix that which should happen automatically - the error message will be shown in the picker as well.
Allan
It only says 'Error' underneath the date picker. I also just tried it with a non-datetime field and I'm getting the same behavior. This is an example JSON I'm sending down for a non-datetime field:
{"data":null,"fieldErrors":[{"name":"BoatNumber","message":"A value is required."}],"error":null}
And an error message appears below the input with the text 'Error' and not the
message
from thefieldErrors
JSON.If I send down a string for
error
at the top level of the JSON then that text displays properly under the input. I would just use that except that text doesn't appear if there are nofieldErrors
and adding a value to that array will force theError
text to display as well as the string value oferror
.I thought
error
was supposed to be a global message but its value appears to be displaying under the cell input.So the error message is for a field that is not the one being inline edited? Unfortunately, error messages for other fields won't be shown since they are already assumed to be valid. It sounds like your server-side validation might be expecting the full data set from the form to be submitted rather than just the value that is being edited. The
form-options
can be used to do that - specifically thesubmit
option which ischanged
by default forinline()
.Allan
The error message is for the value being inline edited. So in the example JSON above, the field being edited is
BoatNumber
. And that field can't be null, so the message from the validation on the server isA value is required
.The server is expecting, and gets, the full data set as I have
formOptions.inline.submit
set toallIfChanged
. Is that right?Thanks for the help!
Is
BoatNumber
a date time field? From your original post the issue is that error messages are not shown when editingdatetime
fields. I had assumed thatBoatNumber
was just a regular input, or perhaps a number input, and not adatetime
.Could you give me a link link to the page so I can fully understand the issue, see the code and be able to debug it please?
Yes, that's correct - that will send the full data set from the form. But if any field that is not the one currently being edited is invalid, the error wouldn't be shown.
Allan
Sorry, I can't link to the page as it's for a client and in development. When the field is datetime, the text "Error" displays inside the time picker at the bottom, and the error from the server displays underneath (z-index wise) the time picker, and so is invisible.
For
BoatNumber
, it's an integer field, but a similar problem occurs. The text "Error" displays below the input with the following HTML:<div data-dte-e="msg-error" class="help-block" style="display: block;">Error</div>
and its parent element is:
<div data-dte-e="input" class="col-lg-8 controls">
The error I sent from the server displays with the HTML:
<div data-dte-e="form_error" class="DTE_Form_Error" style="opacity: 1; display: block;">A value is required.</div>
And its parent element is:
<div class="DTE_Field DTE_Field_Type_text DTE_Field_Name_BoatNumber error has-error">
I only want my error to display. Although now that I'm typing this out I could just hide the one that I don't want in that case.
Displaying the error inside the time picker is more difficult though, and this doesn't seem like the expected behavior?
https://drive.google.com/file/d/0B2y16SYlYbrqMXVyZ3EyVERuQ0k/view?usp=sharing
https://drive.google.com/file/d/0B2y16SYlYbrqWWZBNFJ4WFlqemM/view?usp=sharing
Sorry for the delay in replying.
Actually yes - it is. In 1.5 and earlier the error message wan't shown in the date picker and if the field was in error it would be focused upon, thus showing the calendar picker and covering up the error message. If you didn't have the colouring to show the field as in error it meant you had no idea what was going on.
If you don't want that error message you could use:
Allan