-- debussy007 <[EMAIL PROTECTED]> wrote
(on Thursday, 20 September 2007, 01:33 PM -0700):
> Thank you all for your advices.
> 
> I do not want to use FlashMessenger because I want to avoid creating
> sessions for guests who didn't authenticated, for permance reasons.
> 
> I will opt for the easiest one, set the view variable in the AuthController.
> I think the best solution is to pass the parameter to the IndexController
> since it is not the role of the AuthController to render the view of the
> IndexController, 


The AuthController isn't rendering the view in this case; it's simply
giving the view some information to use in its display logic.


> but the code gets dirty since those kind of operations
> demand some if statements etc.
> 
> 
> Matthew Weier O'Phinney-3 wrote:
> > 
> > -- debussy007 <[EMAIL PROTECTED]> wrote
> > (on Thursday, 20 September 2007, 12:56 PM -0700):
> >> I wondered how to pass info between two controllers. 
> >> Here is the case explained where I need it :
> >> 
> >> I have an AuthController which is responsible for all login/logout
> >> actions.
> >> 
> >> When I notice someone put a bad username and/or password, 
> >> the AuthController forwards the flow to the IndexController which will
> >> render the home page 
> >> and I want to display a message to explain it is a bad user and/or
> >> password
> >> on this home page.
> >> 
> >> So the question is how do I specify that there was a bad connection
> >> attempt 
> >> between the AuthController and the IndexController ?
> >> 
> >> In other words how do I transfer the information between the
> >> AuthController
> >> and the IndexController 
> >> that the connection failed ? What is the best way ?
> > 
> > The fourth parameter to _forward() is an array of paramater values to
> > set in the request object:
> > 
> >     $this->_forward('index', 'index', null, array('error' => 'Bad login
> > credentials'));
> > 
> > You'd then retrieve this in the other controller using _getParam():
> > 
> >     $error = $this->_getParam('error', false);
> >     if ($error) {
> >         // assign error to view?
> >     }
> > 
> > Alternatively, you could simply set a view variable, and check for that
> > in the home page view script:
> > 
> >     $this->view->error = 'Bad login credentials';
> > 
> > Finally, you could use the FlashMessenger helper (as Darby has already
> > noted); this helper is best used for passing messages to subsequent
> > requests.
> > 
> > -- 
> > Matthew Weier O'Phinney
> > PHP Developer            | [EMAIL PROTECTED]
> > Zend - The PHP Company   | http://www.zend.com/
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/Passing-information-between-controllers-tf4489758s16154.html#a12805273
> Sent from the Zend Framework mailing list archive at Nabble.com.
> 

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

Reply via email to