我必须做一些完全错误的,但默认值是没有得到以下ExtJS的形式设置:默认值是没有得到设置ExtJS的表单值
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");
的DefaultType的似乎是键。如果我将defaultType设置为“复选框”,则复选框会被正确检查。如果我将defaultType设置为'textfield',则会填充文本字段。任何想法我做错了什么?
这是正确的,但我仍然不知道为什么。这些控件都呈现正确,他们只是没有得到默认值设置。无论如何,默认为textfield并指定xtype = checkbox,而不是inputType = checkbox解决了问题。 – ConsultUtah 2010-11-15 15:10:03
请参阅我的回答以澄清此问题。 – 2010-11-18 06:15:01