2009-10-20 65 views
0

我有一个远程窗体的contentPane,我试图让窗体提交,并保持在窗格内,不管是在错误还是报告成功时再次显示窗体。 我确信这很容易,但我很难过,不是第一次,也不是最后一次。Zend_Dojo_Form onSubmit

存储格式:

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比例。

编辑:代码很混乱

回答

1

咆哮错误的树。 在我的表单中带有onclick事件的按钮可以做到这一点。

$this->addElement('Button', 'submit', array(
     'label'  => 'Save', 
     'onclick' => 'dojo.xhrPost(
          { 
           url : "url", 
           timeout : 2000, 
           form : "form" 
          } 
         );'