On multiple field errors, field focus is random.
On multiple field errors, field focus is random.
mslattery@misoenergy.org
Posts: 2Questions: 0Answers: 0
When multiple there are multiple field errors in the editor form, the focused field is random. We have a form with 5 fields, all required, and if I leave them all blank (which causes a field error), the focused field is randomly chosen between the first 3. I am even clicking the submit button at the exact same location.
Is there a way to make it always choose the first field that has an error?
This discussion has been closed.
Replies
On this example if you click the "New" button and then submit an empty form, it will always focus on the first field in error. The JSON handling code has a specific case for the
0
loop to make focus only call on that first field.It sounds like the response from the server might not always be in the same order. If that's the case, Editor will always pick the first in the current response. Might that be the case?
Allan
Right. The fieldsErrors returned is coming back in random order from our server. The first element in the array is what dictates the focus (i.e. i=0). It would be better for us if the order was based on the order of the fields array in the editor options.
The server side code is unaware of the field ordering; it returns errors using logic independent of any editor configuration.
At the moment I think you'd need to use the
postSubmit
event to reorder the items in thefieldErrors
array into the same order as the form. A littlesort()
function should be able to do that.There isn't a built in way in Editor to have it handle that case at the moment I'm afraid - it is expecting the errors to be returned from the server in sequential order.
Are you using async validators on the server - is that why they are coming back in a different order each time?
Allan