Editor Forms Question 1: readonly when Editing, text when Adding possible
Editor Forms Question 1: readonly when Editing, text when Adding possible
I am using the Forms to Add/Edit/Delete single entries. For a NEW entry i like to be able to let the user enter a user name. Hence the field should be of type "text". But the same field should not be changed later on by the user via the Edit feature.
How can i do this?
cheers
Juergen
How can i do this?
cheers
Juergen
This discussion has been closed.
Replies
In Editor 1.1, unfortunately this isn't trivial since it doesn't announce that the form is shown and in what state. However, Editor 1.2 is due for release tomorrow and will include new events which will be ideal for this, along with the API.
Specifically the onInitCreate, onInitEdit and onInitRemove events could be used to modify fields. For example:
[code]
editor.on( 'onInitCreate', function () {
editor.enable('name');
} );
editor.on( 'onInitEdit', function () {
editor.disable('name');
} );
[/code]
Having said that, it would be possible to use the onSubmit event in 1.1 to modify the data being sent to the server and simply remove the 'name' field. It isn't as nice a UI though...
Allan
This is super cool, and two super fast answers to my questions !! :-)
Will check it out when V 1.2 is out.
cheers
Juergen
A step further to this, is it possible to conditionally disable a field based on whether it has data in it?
i.e. I have a DATE field and if that field has a value then I do not want it edited again only if it is blank should it be enabled.
Does onInitEdit have access to test the field values?
Thanks.
Allan