views:

228

answers:

1

I have a contentPane with a remote form, I'm trying to get the form to submit, and stay within the pane, either displaying the form again on error or reporting success. I'm sure this is easy but I'm stumped, not the first time and not the last I'm sure.

Store Form :

    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);
    }
}

My View :

    <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; ?>

Fairly new to all this, so apologies for the lines to wtf ratio.

Edit : code was messy

A: 

Barking up the wrong tree. A button with onclick event in my form does the trick.

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