我尝试使用ext4yii表单插入数据。但保存功能不起作用。请仔细查看我的代码
formpanel的代码
<ext:Window ClassName="WelcomeWindow" width="500" iconCls="IconApplication"
bodyPadding="25" bodyStyle="background-color:#fff" layout="fit"
title="<?php echo Yii::app()->name;?>" closable="false"
maximizable="false">
<prop:Items>
<ext:FormPanel itemId="form1" width="300" title="myform" autoScroll="true">
<prop:Form>
<ext:CRUDForm controller="ContactForm" />
</prop:Form>
<prop:DockedItems>
<?php
include 'ContactView_Editor_Toolbar.php';
?>
</prop:DockedItems>
<prop:Items>
<ext:TextField name="Name" fieldLabel="Name"/>
<ext:TextField name="address" fieldLabel="Address"/>
</prop:Items>
<prop:InstanceBody>
<script>
(function(){
return {
StartSaveContact:function()
{
var me = this;
me.mode='new_contact';
var msg = me.mode == 'new_contact' ? 'New contact created successfully.' : 'Contact saved successfully.';
var form = me.getForm();
if(form.isValid()) {
var lm = Ext4Yii.newLoadMask(me,'Please wait...',true);
form.submit({
params:{
mode:me.mode
},
success:function(form,response) {
lm.hide();
Ext.MessageBox.show({
title: me.title,
msg: msg,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO,
fn:function() {
}
});
},
failure:function(form,response) {
lm.hide();
Ext.MessageBox.show({
title: me.title,
msg: response.result.message,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR,
fn:function() {
}
});
}
});
}
}
}
})()
</script>
</prop:InstanceBody>
</ext:FormPanel>
</prop:Items>
</ext:Window>
contactformcontroller的代码
class ContactFormController extends ExtFormController
{
public function load($request) {
}
public function save($data)
{
$customer = new Employee();
/**
* We can use the setAttributes method on the Customer model
* since the form names have the same name as the attributes.
*/
$customer->setAttributes($data);
if( $customer->save())
$this->exportData($customer);
else
$this->exportException("Don't know what to do..");
}
}
失败功能是在不显示任何消息的情况下进行的。
感谢您提前
答案 0 :(得分:0)
如果你看看萤火虫,你会得到什么样的错误?