我必須做一些完全錯誤的,但默認值是沒有得到以下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