我有一个带有远程表单的 contentPane,我试图让表单提交,并留在窗格内,或者在错误时再次显示表单或报告成功。我敢肯定这很容易,但我很困惑,我敢肯定,这不是第一次,也不是最后一次。
店铺形式:
class Services_Form_Store extends Zend_Dojo_Form {
protected $_actionUrl;
public function __construct($actionUrl = null, $options=null)
{
parent::__construct($options);
$this->setActionUrl($actionUrl);
$this->init();
}
public function setActionUrl($actionUrl) {
$this->_actionUrl = $actionUrl;
return $this;
}
public function init()
{
$required = true;
$this->setMethod('post')
->setAttrib('id', 'storeform')
->setAttrib('name', 'storeform')
->setAttrib('onSubmit', 'dojo.xhrGet(sub) return false;');
$this->addElement('TextBox', 'location', array(
'label' => 'Location name :',
'required' => true,
'trim' => true,
'propercase' => true)
);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('save');
$this->addElement($submit);
}
}
我的观点 :
<script type="dojo/method" event="onSubmit">
var sub = {
url : "/storemamager/new",
load : function(data){
dojo.byId('storeform').value = data;
},
error : function(data){
console.debug("error submitting data :" + data);
},
timeout : 2000,
form : "storeform"
}
</script>
<?php echo(empty($this->formResponse) ? '' : '<p class="errors">' . $this->formResponse . '</p>'); ?>
<?php echo $this->form; ?>
这一切都相当新,所以为线路与 wtf 的比率道歉。
编辑:代码很乱