Changing aspects of fields for edit vs new

Changing aspects of fields for edit vs new

aaronwaaronw Posts: 89Questions: 3Answers: 4
edited June 2013 in Editor
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]

Replies

  • allanallan Posts: 61,734Questions: 1Answers: 10,110 Site admin
    That's only changing the internal property - which Editor doesn't have a property event listener on, so it doesn't know that it has changed. In general, the `s` (settings) parameters shouldn't be changed externally at all, as they are internal properties.

    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
This discussion has been closed.