Standalone editor initial values
Standalone editor initial values
It would be nice if there was a javascript way to set initial values for the editor form that works well with submitting changed values only. When doing editor.edit(id).set(values)
, the default values will be used for comparison, not the values that were set by me immediately after creating the form.
Some possible solutions:
- an editor.setInitial(values)
function that not only sets the current state, but also overrides the values that were recorded when starting the edit (editor.s.editData
)
- add a parameter to editor.set()
to force the above behaviour
- add a parameter to editor.edit()
to prevent overriding the current state, so that editor.set(values).edit(id)
works as expected.
For now, I'll just use
editor.s.editData = $.extend( true, {}, editor.multiGet() );
Answers
That is correct. When the edit method is called it will cache the values at that time - before any external set has taken place.
If it is the default that you want to alter, you could use
field().def()
before calling the edit or create methods. Then the cached values will be the defaults that have been set.Allan
The problem is that changing the default values isn't ideal either, because 1) I can't use the
editor.set(object)
function, and 2) I also use the form increate
mode, which needs empty default values. Of course I could change the default values every time before I open the form, but I prefer the current solution over that.