|
|
Re: How to populate a select form element from a different module/controlle: msg#00123
php.zend.framework.mvc
|
Subject: |
Re: How to populate a select form element from a different module/controller/model? |
Personally, in this case I would create a view helper specifically to
render the language selection. Typically, in a site, you have a limited
set of these kinds of data-aware UI controls, so I would just create a
specific model-based view helper to encapsulate each one. However, this
is a pretty subjective thing, and you should feel free to take any other
approach you see useful for your specific requirements.
Regards,
Bryce Lohr
Codiac wrote:
Bryce,
Excellent points, thanks!
I'll check the option to have Zend_Form use that view helper.
Would you actually create a dedicated view helper to retrieve the list of
languages or a more generic/abstract helper, that can load data from
different models (with a lot more complexity)?
Regards, TJ.
Bryce Lohr-2 wrote:
Creating a view helper that uses the Language model to pull the list of
languages is a perfectly valid solution to this problem. I would assume
you could then tell Zend_Form to use that view helper to display the
drop down.
Also, there's no technical reason why models can't access other models.
Whether you do so or not is entirely up to you and how you want your
application's architecture to work. It's probably not a good idea to
force models to depend on controllers to access other models, since the
whole model layer is better off being completely independent of the
controllers (or any other code that uses it). Think about what you'd
have to do if you had to build a CLI version of the application: you'd
probably need different controllers, which would break many models, but
you still need the same business logic.
Regards,
Bryce Lohr
|
|