【问题标题】:Setting module for Zend Form ViewScript decoratorZend Form ViewScript 装饰器的设置模块
【发布时间】:2012-03-18 21:45:00
【问题描述】:

我正在尝试为我的表单提供一个视图脚本装饰器,如下所示:

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()))));
}

但是,我不想使用默认模块;我想根据表单的类名加载特定的视图脚本。由于我可能在多个模块中使用特定表单,因此我希望所有表单视图脚本都位于 ./application/form/views/scripts/ 中。

但是,我无法将模块设置为“表单”,而不是当前模块。谁能提供见解?

谢谢

【问题讨论】:

    标签: php model-view-controller zend-framework zend-form decorator


    【解决方案1】:

    我查看了 Zend 的代码,发现你可以设置 viewscript 的模块,如下例所示:

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

    这应该可以,我也在我的项目中使用它。

    【讨论】:

      【解决方案2】:

      你试过这个解决方案吗?

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

      我没有检查它,但认为它应该可以工作

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-09
        • 2010-12-10
        • 1970-01-01
        • 2011-01-09
        • 1970-01-01
        • 2011-11-27
        相关资源
        最近更新 更多