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

0

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.