I believe you are confusing MVC modules and what you are calling "Page
Modules". It sounds like you need one module and a few models.
Pages_Model_Page has many Pages_Model_Module.
Each, Pages_Model_Module, has one form (Pages_Form_Module_*) and getForm()
method to get the form for the module. In the getForm() you can create a new
instance of the "Module" form and fill it will the data for the "Module".
Per "Page", get the "Modules", put each form, as a sub-form, in a standard
Zend_Form and then pass to View. Upon submission, repeat above to build form,
then validate. If valid, loop through each module and apply changes.
With this approach you have one model and form for each "Page Module"
(text,image,form,rss,video) and when you need a new one, you just create a
model and form.
Need further info, let me know.
On Jan 14, 2011, at 1:10 PM, Jurian Sluiman wrote:
> Hi all,
>
> I'm a bit stuck about the architecture I need to design and hope some of you
> can give me some hints.
>
> A certain action controller needs to build a page containing a Zend_Form
> instance and some html. The form contains subforms which are generated by
> other modules. The html is concatenated by rendered view scripts of different
> modules.
>
> So in pseudo code:
> $form = new Zend_Form;
> $html = '';
> foreach ($modules as $module) {
> $form->addSubform($module->getForm());
> $html .= $module->getHtml();
> }
>
> And the question is: what should $module be: a service layer, a model, a
> action controller, something else?
>
> After the form has been posted, the system needs to return all the values of
> the subforms to the appropriate modules. Currently I use service objects in
> the service layer ({Module}_Service_Admin), but this single class becomes
> very
> heavy. Think of a portfolio service class which needs to be able to create,
> update and delete portfolios, portfolio categories and portfolio projects and
> provide listings of categories and projects. It becomes really heavy.
>
> If you can give any advice, that would be great! Thanks in advance,
> Best regards, Jurian
>
> PS. I posted this question with a slight longer story at SO:
> http://stackoverflow.com/questions/4679334/architecture-advice-of-zf-admin
> --
> Jurian Sluiman
> Soflomo - http://soflomo.com
Shawn Ostler
InclusiveDv
[email protected]
801-688-6946