2009-10-20 5 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; ?> 

, 선에 대한 사과는 비율을 무슨 수 있도록.

편집 : 코드가 엉망이었습니다.

답변

1

잘못된 트리를 짖어 내고 있습니다. 내 양식에서 onclick 이벤트가있는 버튼이 트릭을 수행합니다.

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