Changing aspects of fields for edit vs new
Changing aspects of fields for edit vs new
So I'm trying to have a certain field be available for input on a ADD, but have that same field be readonly for an edit. (I'll figure out how to populate it later....)
I'm trying to do it this way, but it's not working the way I intend it. Strangely enough, it always seems to be readonly, even on the first console.log, so I'm kind of confused (even though the field is only readonly if I set it as such in the fields/type section of the init object.
[code]
editor.on('onInitEdit',function(e)
{
console.log (e.target.s.fields[0]);
e.target.s.fields[0].type ="readonly";
console.log (e.target.s.fields[0]);
});
[/code]
I'm trying to do it this way, but it's not working the way I intend it. Strangely enough, it always seems to be readonly, even on the first console.log, so I'm kind of confused (even though the field is only readonly if I set it as such in the fields/type section of the init object.
[code]
editor.on('onInitEdit',function(e)
{
console.log (e.target.s.fields[0]);
e.target.s.fields[0].type ="readonly";
console.log (e.target.s.fields[0]);
});
[/code]
This discussion has been closed.
Replies
However, you could use the 'node' method to do what you are looking for:
[code]
$('input', editor.node( 'myField' ) ).prop( 'readonly', true );
[/code]
i.e. get the 'input' event from the field 'myField' and set the readonly property.
Regards,
Allan