Standalone editor initial values

Standalone editor initial values

RagnarGrootKoerkampRagnarGrootKoerkamp Posts: 48Questions: 14Answers: 1
edited April 2017 in Editor

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

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    the default values will be used for comparison, not the values that were set by me immediately after creating the form.

    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

  • RagnarGrootKoerkampRagnarGrootKoerkamp Posts: 48Questions: 14Answers: 1

    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 in create 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.

This discussion has been closed.