Here's what I do. $this->_helper->DropDown->hardware($sql);
"DropDown" is the name of the Helper. "hardware" is the name of the method in the helper that I want to access. Gina-Marie Rollock -----Original Message----- From: Matthew Lurz [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 30, 2008 10:41 AM To: [email protected] Subject: Re: [fw-general] Action Helper Perhaps an example will help: http://www.paste2.org/p/80416 As you can see, generatePassword is called in the direct method and so if I want to generate a new password I can simply call: $pw = $this->_helper->passwordGenerator(); If there were other methods in this helper that I wanted to access I would first need to get an instance of the helper with: $pwGen = $this->_helper->getHelper('PasswordGenerator'); And then I could call any other method of the helper. $pwGen->someOtherMethod(); Hope that makes more sense. maxarbos wrote: > > But if there is more than one method in that helper, how does it know > which method to call? > > The code I have within my helper class for the direct method is this: > > public function direct($method){ > return $this->$method(); > } > > > > > > > Matthew Lurz wrote: >> >> The documentation is correct. The direct method, if implemented in the >> action helper, will call a specific, default method in the helper. In the >> case of the FlashMessenger this is the addMessage method. So, calling >> $this->_helper->FlashMessenger('Some Message') will execute the direct >> method of the action helper. The direct method then calls addMessage(). >> >> Hope that helps. >> >> >> maxarbos wrote: >>> >>> Hello, >>> >>> I would like to pass a value to to a specific property inside of a >>> helper when I use it. >>> >>> On page: >>> http://framework.zend.com/manual/en/zend.controller.actionhelpers.html >>> >>> In the documentation is says this: >>> >>> #Finally, most action helpers implement the method direct() which will >>> call a specific, default method in the helper. In the example of the >>> FlashMessenger, it calls addMessage(): >>> >>> $this->_helper->FlashMessenger('We did something in the last request'); >>> >>> // shouldnt this last line be: >>> $this->_helper->FlashMessenger('addMessage'); ? >>> >>> How do you get the message you want to add to 'addMessage' to that >>> method? It would be great to be able to send a valu that is read into >>> the constructor. >>> >>> >>> >>> >>> >> >> > > -- View this message in context: http://www.nabble.com/Action-Helper-tp19730400p19743475.html Sent from the Zend Framework mailing list archive at Nabble.com.
