Datetime field not showing error message from server

Datetime field not showing error message from server

finsight-akfinsight-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?

Answers

  • allanallan Posts: 63,852Questions: 1Answers: 10,519 Site admin

    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

  • finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0

    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 the fieldErrors JSON.

  • finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0

    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 no fieldErrors and adding a value to that array will force the Error text to display as well as the string value of error.

    I thought error was supposed to be a global message but its value appears to be displaying under the cell input.

  • allanallan Posts: 63,852Questions: 1Answers: 10,519 Site admin

    This is an example JSON I'm sending down for a non-datetime field:

    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 the submit option which is changed by default for inline().

    Allan

  • finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0

    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 is A value is required.

    The server is expecting, and gets, the full data set as I have formOptions.inline.submit set to allIfChanged. Is that right?

    Thanks for the help!

  • allanallan Posts: 63,852Questions: 1Answers: 10,519 Site admin

    Is BoatNumber a date time field? From your original post the issue is that error messages are not shown when editing datetime fields. I had assumed that BoatNumber was just a regular input, or perhaps a number input, and not a datetime.

    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?

    The server is expecting, and gets, the full data set as I have formOptions.inline.submit set to allIfChanged. Is that right?

    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

  • finsight-akfinsight-ak Posts: 19Questions: 5Answers: 0

    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?

  • allanallan Posts: 63,852Questions: 1Answers: 10,519 Site admin

    Sorry for the delay in replying.

    Displaying the error inside the time picker is more difficult though, and this doesn't seem like the expected behavior?

    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:

    div.editor-datetime-error {
      display: none;
    }
    

    Allan

This discussion has been closed.