-- Roberto Bouza <[EMAIL PROTECTED]> wrote
(on Tuesday, 04 March 2008, 10:08 PM -0500):
> I've been doing some forms and the way I'm assigning the
> Zend_Translate object to the Zend_Form object is like this:
>
> $form->setTranslator(Zend_Registry::get('my_translate'))
>
> As you can see I have a different name that we have been using for a
> while now 'my_translate'.
You could also do this:
Zend_Registry::set('Zend_Translate', Zend_Registry::get('my_translate'));
somewhere in your code to have them be aliases. This would give you the
benefits of the documented methods for setting up global Zend_Translate
objects, as well as not require you to change any of your custom code.
> I know that Zend_Form picks up the 'Zend_Translate' object using that
> same name as the key so you don't have to do the 'setTranslator' every
> time on your controllers.
>
> Now on the other hand I have a custom Zend_View implementation using
> Smarty, so when I create the View on the bootstrap I set up first the
> translator and then add the view to the action_helper_viewrenderer
> which uses that on all the views I will generate from now on.
>
> The final question is. It is possible that Zend_Form picks up the
> Zend_Translate object from the View, without getting it out from the
> registry or the view manually on each controller?
No; it doesn't make sense architecturally to pull it from the view
object for a variety of reasons. We push the translate object into the
form because you may not be using Zend_View (or any view object, for
that matter) with Zend_Form, and this allows the developer direct access
to the translate object when creating custom decorators.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/