fieldErrors seem to be not working

fieldErrors seem to be not working

matthewjmatthewj Posts: 39Questions: 2Answers: 0
edited June 2013 in Editor
I was trying to display a message on a field after doing server validation but the edit form doesn't seem to display it. below is my json
[code]
{"id":185265,"fieldErrors":[{"uname":"Username is mandatory!"}],"aaData":{}}

[/code]

any pointers?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    The return format is slightly different from what you are using. Each error object has two fields, `name` and `status` where the name is the field name in error and status is the string to show.

    So you'd want to return:

    [code]
    {
    "id": 185265,
    "fieldErrors": [
    {
    "name": "uname",
    "status": "Username is mandatory!"
    }
    ],
    "aaData": {}
    }
    [/code]

    Allan
  • matthewjmatthewj Posts: 39Questions: 2Answers: 0
    Thank you very much Allan. It worked!
  • matthewjmatthewj Posts: 39Questions: 2Answers: 0
    Also I think id and aadata are not required in the return json, ie below would suffice.


    {"fieldErrors":[{"name": "uname","status": "Username is mandatory!"]}
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    That is correct. I think its in my examples as it was easier to write the libraries that way, but only fieldErrors is needed if there is actually an error.

    Allan
This discussion has been closed.