I didn´t understand it very well, but here are some tips that maybe help
you.

Dont´t build Forms inside controllers, make a separated class extending
Zend_Form to define it, then use it in the controllers. If you need to
construct it with some data, you can make a method in the Form class to do
it.

Example to ilustrate:

Form

<?php
>
> class Blog_Form_Post extends Zend_Form {
>     public function init()
>     {
>         $this->setMethod('post');
>
>         $id = $this->createElement('hidden','idPost');
>         $this->addelement($id);
>
>         $texto = $this->createElement('textarea','text');
>         $texto->setLabel('Text:')
>               ->setAttrib('size',50);
>         $this->addelement($texto);
>
>         $salvar = $this->createElement('submit','salvar');
>         $salvar->setLabel("Salvar")
>                ->setIgnore(true);
>         $this->addelement($salvar);
>     }
>
>     public function setIdPost($id)
>     {
>         $this->getElement('idPost')->setValue($id);
>     }
> }
>

Controler

public function editFormAction()
> {
>     $post = $this->getRequest()->getPost();
>     $form = new Blog_Form_Post();
>     $form->setIdPostValue($post['idPost']);
>
>     $this->view->form = $form;
> }
>


Now you can use it anywhere, even outside Blog module



::: Diego Potapczuk

»» Analista de sistemas
»» Tel: (71) 3287-8343 / (71) 9144-3062
»» http://www.diegoliveira.com.br


On Wed, Dec 2, 2009 at 7:08 PM, Jurian Sluiman <[email protected]> wrote:

> Hi all,
> Is it possible to fetch the return value from a certain function inside an
> action controller?
>
> This is the use case: I have ad admin module and a specific controller.
> This
> controller builds a form to edit some data. The data might come from
> another
> modules, so I call the admin-controller from that module.
> I want to have something like this (pseudo code):
>
> admin-module/controller-action:
>
>> $form = new Zend_Form;
>
> $subform = someMagicFunction('blog', 'admin', 'getForm');
>
> $form->addSubform($subform);
>
>
> Is this possible to achieve? Currently I fetch the results with a custom
> dispatcher, but that's imho an ugly hack...
>
> Regards, Jurian
>

Reply via email to