1

I am trying to give my form a view script decorator like so:

public function setupViewScript() { 
    //Work out the path based on the class name here
    //****

    //Set decorator
    $form_decorator->setViewScript($form_view_path);
    $this->setDecorators( array( array('ViewScript', array('viewScript' => $form_decorator->getViewScript()))));
}

However, I don't want to use the default module; I want to load a specific view script depending on the form's class name. Since I may use a particular form in multiple modules, I want all of my form view scripts to be in ./application/form/views/scripts/.

I'm having trouble setting the module to be "form", instead of the current module, however. Can anyone provide an insight?

Thanks

James
  • 1,950
  • 3
  • 22
  • 39

2 Answers2

3

I looked into the code of Zend and found u can set the module of the viewscript as in the following example:

$this->setDecorators(array(
        array('ViewScript', array('viewScript' => '<viewscriptname>', 'viewModule' => '<modulename>')),
        'Form'
    ));

This should work, i use it in my projects as well.

0

Have you tried this solution?

$request = Zend_Controller_Front::getInstance()->getRequest();
$request->setModuleName('form');

I didn't check it but think it should work

Marek
  • 1