-- Ian Warner <[EMAIL PROTECTED]> wrote
(on Tuesday, 27 February 2007, 04:35 PM -0000):
> Worked fine thank you very much

Just for the historical record (for those who may search for this), what
worked for you -- using the response object, or updating how you called
_forward()?

> > > I am trying to make sense of the Forward command.
> > >
> > > I am utilizing QuickForm in a join form
> > >
> > > The user fills in the form if it validates I want to forward to a
> > validate
> > > Action - just for separation.
> > >
> > >         // Try to validate a form
> > >         if ($form->validate()) {
> > >
> > >           // Email and store in DB
> > >             // Forward to the Verification controller
> > >             self::_forward('validate');
> > 
> > First, Zend_Controller_Action::_forward() is not a static method.
> > Second, make sure you understand its signature:
> > 
> >     protected function _forward($action, $controller = null, $module =
> > null, array $params = array());
> > 
> > It works like this:
> > 
> >     * If only an $action is provided, it forwards to that action in the
> >       current controller and module
> >     * If an $action and a $controller are provided, it forwards to that
> >       action and controller in the current module
> >     * If an $action, $controller, and $module are provided, it forwards
> >       to that action and controller in the provided module.
> >     * $params may be provided at any time (pass null to any unneeded
> >       parameter), and will be used to set parameters in the request
> >       object.
> > 
> > >
> > >         } else {
> > >             $string = $form->toHtml();
> > >         }
> > >
> > > Now in my validate action I want to forward again to the second stage of
> > the
> > > form
> > >
> > >     // Show second stage
> > >     public function validateAction()
> > >     {
> > > //        $post = Zend::registry('post');
> > > //        echo '<pre>'; print_r($post); echo '</pre>';
> > > //        echo '<pre>'; print_r($_POST); echo '</pre>';
> > >
> > >         // Forward to the Verification controller
> > >         self::_forward('index', 'verification');
> > >     }
> > >
> > > Which involves verification
> > >
> > > However when I get here I have the output of all the previous pages.
> > >
> > > So my question is
> > >
> > > 1. How do I stop output from the action the script forwarded from. Is
> > this
> > > something to do with the Dispatch stuff - can I clear this before I
> > forward
> > > maybe?
> > 
> > Use the response object's setBody() and appendBody() methods for
> > displaying content. So, instead of:
> > 
> >     echo '<pre>', print_r($post, 1, '</pre>';
> > 
> > You'd use:
> > 
> >     $this->_response->appendBody('<pre>' . print_r($post, 1) . '</pre>');
> > 
> >     // or
> >     $this->getResponse()->appendBody('<pre>' . print_r($post, 1) .
> > '</pre>');
> > 
> > Then, if you want a particular action to always overwrite any previous
> > content, use setBody():
> > 
> >     $this->_response->setBody('Thanks for verifying your identity');
> > 
> > You could also do this just before your call to _forward():
> > 
> >     $this->_response->setBody('');
> >     $this->_forward('index', 'verification');
> > 
> > > 2. What performance penalty do I suffer for letting the script compile
> > and
> > > then I clean?
> > 
> > Not much -- it's all being handled as PHP arrays; you're simply
> > unsetting previous values.
> > 
> > --
> > Matthew Weier O'Phinney
> > PHP Developer            | [EMAIL PROTECTED]
> > Zend - The PHP Company   | http://www.zend.com/
> 

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to