Form clear behavior

Hello,

I’ve noticed a strange behavior with form clear. Take the following form for example: http://webix.com/snippet/7fb3c56f

Correct me if I’m wrong but I would expect that the richselect to be set to the value of 1 (which is the original value set to the component configuration) instead of just erasing it.

Is this the expected behavior? If so, how could I make clear retrieve the original fields’ values?

I would like to point out that webix code (https://cdn.webix.com/edge/webix_debug.js), more specifically the form’s clear function:

data[name] = this.elements[name]._settings.defaultValue||"";

that would suggest a possible way to set a defaultValue.

as a workaround you can cache “original values” and set them instead of clear. http://webix.com/snippet/bc8d1d65

Yes I could do that. But since I want this same behavior for all forms in may application, that would be a lot of work and difficult to maintain.

Perhaps, I can ‘proto’ a new form that would save the form values after it’s initialization and I could implement a custom ‘reset’ function. I just don’t know how to get this values after the form initialization.

$(‘myForm’).getCleanValues() will retrieve the original values and the I can set them to the form.

[EDIT]

This actually won’t work. If I setValues in a form, then these values will be the response to getCleanValues()

getCleanValues() won’t handle setValues. It was intended to allow setting the initial values separately, for instance.

However, you can combine the @intregal’s workaround with getCleanValues().