Pre-set data choice/text for user in editor.create?

Pre-set data choice/text for user in editor.create?

aveakaveak Posts: 15Questions: 0Answers: 0
edited August 2012 in Editor
For a particular application I'm creating, I need the user to be able to open a new editor.create dialog, but I need to be able to, depending on that they clicked, pre-select from a field:"select" or pre-fill a field:"text".

I've concluded that I need to do this in onInitCreate() -- but how do I send values into that scope?

To be clear: I'm not setting a default value for a field, as the values I'd like to fill in are only contextually relevant to the user's initial click.

Replies

  • aveakaveak Posts: 15Questions: 0Answers: 0
    edited August 2012
    Ah, answered my own question. It's not in the onInitCreate event. At the same scope at which you call editor.create, you then, as a second step, call editor.set(fieldname, value).

    Sure glad I post here, or I wouldn't be able to solve these things for myself in public. ;P
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    edited August 2012
    The `onInitCreate` event could be used, but the scoping of parameters makes it a little bit awkward since you need to get the value(s) you want in to the function, or in some other way tell the event handler what to do. However, I'd say that your approach of using the more general API such as `set` is the way to go, if you are calling `create` yourself. It might be an idea to call `set` first, as that will pre-populate the field before the form is shown - although on the majority of computers it should happen so fast that calling it second shouldn't be visible to the end user.

    Regards,
    Allan
This discussion has been closed.