View Full Version : Enable then dsable a field - FIXED

22 Nov 2007, 4:06 AM
I have also added this to the ext 1.1 forum as it applies to both

I have a field on a form which is disabled (as I want a certain form and style of text placed in there) - when the user presses a button, they get a popup box and they type in there. When they press OK that text gets written back to the field and some autid text is placed in there also. This works well until the doc is saved - no data is saved with the doc as the field is read only. Is it possible that in the fuction that writes the text back to the field, enable the field, write the text then disable it again

This is the code for the field

var grow = new Ext.form.TextArea({
disabled: true,
autoHeight: false,
width:600, grow:true

Here is the code for the message box

var btn1 = new Ext.Button('mb2', {text: 'Add your Comments' , handler :
title: 'Comments',
msg: 'Please enter you ideas/ comments',
buttons: Ext.MessageBox.OKCANCEL,
multiline: true,
fn: showResultText1.createDelegate(this), // Set scope or 'this' in function to scope of this function which is Comments
animEl: 'mb2'
})}, scope : grow});

Here is the code for the function that is called

function showResultText1(btn1, text){
this.setRawValue(this.getRawValue()+"Comments added by "+ authorName+ " on "+ myDate +"\r"+text+"\r"+"\r");
this.autoSize(); // Grow field

23 Nov 2007, 1:39 AM
I have tried the following but with no success

But with no success - is there any way of doing this

23 Nov 2007, 10:40 AM
are you sure your data is actually getting posted to the server for this field?

23 Nov 2007, 2:03 PM

If i just use this.enable.... it enables the field and saves the data but if i set it to disable at the end - none of it saves

Basically i need to make the field read only so they cannot edit it - if there is another way round

23 Nov 2007, 10:00 PM
Can you not enable the fields as part of your submit routine?

24 Nov 2007, 1:25 AM
i can do but i don't want them to type in the field at any point before the submit

24 Nov 2007, 7:48 PM
Perhaps hide it then enable it then submit?

25 Nov 2007, 2:35 AM
Would that work if i have a computed field looking up to it only showing if the editable one is hidden ?

25 Nov 2007, 1:11 PM
Would that work if i have a computed field looking up to it only showing if the editable one is hidden ?

No as the computed field will not automatically be updated. The field will only have the value that it gets onload.

25 Nov 2007, 3:09 PM
so i am back to square one again - is there any other way i can get round this ?

26 Nov 2007, 12:44 PM
Have about instead of disabling the field make it readonly:


That way it cannot be typed to yet it still gets submitted?

26 Nov 2007, 12:51 PM
Could i render this field like the others - it using the ext style ?

26 Nov 2007, 1:27 PM
Could i render this field like the others - it using the ext style ?

I think so. Only one way to find out

26 Nov 2007, 1:28 PM
true - will test it tomorrow and see

26 Nov 2007, 2:17 PM

Just checked the other forum and suggested I can use instead of disabled: true, use readOnly: true and this will get submitted

Will try and confirm

27 Nov 2007, 3:29 AM
Confirmed it does work - so no need to enable then disable the field.