I'll quickly run throught the solution I used.

http://pastie.org/344914

So in your custom element you have to set a public array called $options.
In the constructor I set up the defaults, the setOptions() method loops
through the array perpend each key with 'set' and capitalising the first
letter of the key. So this calls my functions to set the options in the
options array. When the viewHelper decorator is calling the view helper it
fetches the $options array from your element and pops it into the 4
parameter of your helper.

So now in your viewhelper the 4th parameter is now populated and you can use
the options.



Matthew Weier O'Phinney-3 wrote:
> 
> -- petewilliams1983 <[email protected]> wrote
> (on Monday, 22 December 2008, 05:02 AM -0800):
>> I'm trying to do exactly the same thing. So far the best solution I can
>> come
>> up with is to pass my custom options in via either the $attribs or
>> $options
>> arrays. You can then process those options within your view helper, and
>> delete them from the array so that they aren't added to the element
>> markup.
>> 
>> However I'm pretty sure this isn't the best way of doing things.
> 
> Actually, this is exactly how it should work. :)
> 
> If you look at the current decorator implementations, they pass the
> attributes set in the element directly to the view helper as the
> $attribs array.
> 
> -- 
> Matthew Weier O'Phinney
> Software Architect       | [email protected]
> Zend Framework           | http://framework.zend.com/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Custom-form-element---passing-options-to-viewHelper-tp21073843p21131131.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to