automatically clear error on field-change?

automatically clear error on field-change?

BelortaBelorta Posts: 13Questions: 3Answers: 0

If a field has an error, and the user changes that field to fix the error, then the errormessage is still shown. This is fixable for example with a dependency on each field, which does an editor.field(xxx).error(''). It's a lot of extra code if you have to define this for each field. Is there an easier way to do this? If not, then maybe an option for this can be addad in a future version?

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    The issue here is that the client-side doesn't know if the newly modified data is valid or not. For example, if you have a string which requires three characters, if the user submits a then they will get an error message. If they then use ab it will still be in error, but Editor can't know that (on the client-side) until it is submitted, unless you implement validation logic on the client-side as well. So the error can't just be cleared immediately on the next change - it is held in place until the next submit.

    Using dependent() is the way to handle this at the moment if you want different behaviour.

    Allan

  • BelortaBelorta Posts: 13Questions: 3Answers: 0

    I understand. Another way is to assume that the user fixes an error while entering (or changing) the data, and await the submission of the form so that the server-side can give an error again. In my head that would be more intuitive.

    As you suggest, I'll work around this with the dependent api... Can you can put this on your todo list for a next version?

This discussion has been closed.