I must be doing something completely wrong, but the default value isn't getting set for the following ExtJs form:
var simple = new Ext.FormPanel({
labelWidth: 75, // label settings here cascade unless overridden
frame:true,
title: 'Edit User',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'checkbox'
items: [{
inputType: 'textfield',
fieldLabel: 'Email',
name: 'user[email]',
id: 'user_email',
vtype: 'email',
value: '[email protected]'
},{
inputType: 'password',
fieldLabel: 'Password',
name: 'user[password]',
id: 'user_password',
allowBlank: false,
value: 'password'
},{
inputType: 'checkbox',
boxLabel: 'Is One',
labelSeparator: '',
name: 'user[is_one]',
checked: true
},{
inputType: 'checkbox',
boxLabel: 'Is Two',
labelSeparator: '',
name: 'user[is_two]',
checked: true
},{
inputType: 'hidden',
name: 'authenticity_token',
value: '<%= form_authenticity_token %>'
},{
inputType: 'hidden',
name: '_method',
value: 'put'
}
],
buttons: [{
text: 'Save',
handler: function(){
if(simple.getForm().isValid()){
simple.getForm().submit({
url: '/users/<%= @user.id %>',
waitMsg: 'Saving...',
success: function(simple, o){
msg('Success', 'done');
}
});
}
}
},{
text: 'Cancel'
}]
});
simple.render("user-form");
The defaultType seems to be the key. If I have defaultType set to 'checkbox', the checkboxes get checked appropriately. If I have defaultType set to 'textfield', the text fields get populated. Any ideas what I am doing wrong?