PDA

View Full Version : [CLOSED][3.1] hidden field does not get posted if it is the first form field



wceuppens
24 Jan 2010, 8:26 AM
Ext version tested:
Ext 3.1 rev 0


Adapter used:
ext


Browser versions tested against:
FF3 (firebug 1.3.0.10 installed)


Operating System:
WinXP Pro


Description:
When a hidden field is the first field in a form, it does not get posted when the form is submitted.

Test Case:


centre1.users.fields = [

{
name : 'id',
xtype : 'hidden'
}, {
fieldLabel : centre1.users.lang.user,
name : 'user',
xtype : 'textfield',
maskRe : /[a-z]/i,
allowBlank : false,
emptyText : centre1.users.lang.emptyField
}
]

The post result that was expected:
id 99
user danny

The post result that occurs instead:
user danny

What does work:
When I define the hidden field after the textfield, the hidden field is posted correctly.

Code that gives the expected result


centre1.users.fields = [

{
fieldLabel : centre1.users.lang.user,
name : 'user',
xtype : 'textfield',
maskRe : /[a-z]/i,
allowBlank : false,
emptyText : centre1.users.lang.emptyField
}, {
name : 'id',
xtype : 'hidden'
}
]

jay@moduscreate.com
24 Jan 2010, 9:34 AM
I can't reproduce this.

jay@moduscreate.com
24 Jan 2010, 9:35 AM
how are you setting the form values? Can you see the hidden field in the DOM?

It should look like: http://tdg-i.com/img/screencasts/2010-01-24_1235.png

wceuppens
24 Jan 2010, 9:49 PM
I have no problems reproducing AND the same problem occurs in IE8.

The hidden field appears in the dom (bug1)

The working example (with the hidden field after the first non-hidden) shows the following in the dom (bug2)

I'm loading the form from a database record and id is shown in the json data in both cases.
After changes, I'm submitting the form to update the changes and in the non-working case the hidden 'id' is not posted.

I'm submitting using this code:



centre1.users.formButtonHandler = function(button) {
if (button.iconCls == 'icon-cancel') {
centre1.users.window.hide();
} else {
// alert('button with class <' + button.iconCls + '> pressed.');
var action = button.iconCls.substring(5);
centre1.users.form.getForm().submit({
url : 'php/base.centre1.users.users.php',
success : function(){
centre1.users.store.reload();
centre1.users.window.hide();
},
// failure : <handler(form, action)>,
params : {action: action}
})
}
};

evant
24 Jan 2010, 10:02 PM
What happens if you change the field name from id to something else?

wceuppens
24 Jan 2010, 10:06 PM
Found MY mistake :">, sorry to bother you:

I am using the same form for add, update and delete.
For update, I disabled the user field:



for (i=0; i<centre1.users.form.items.length; i++) {
if (from.iconCls == 'icon-add' || (from.iconCls == 'icon-updateUser' && i > 0)) {
centre1.users.form.items.items[i].enable();
} else {
centre1.users.form.items.items[i].disable();
}
centre1.users.form.items.items[i].setRawValue(undefined);
centre1.users.form.items.items[i].clearInvalid();
}



I added the hidden field afterwards, and the code above disabled not the user, but the hidden field.