Mat*_*lee 13 php zend-framework zend-form
在Zend视图助手中,有用于根据路由表输出URL的函数url(),例如
$this->url(array('controller' => 'comments', 'action' => 'add')
Run Code Online (Sandbox Code Playgroud)
如何在控制器中执行相同的操作?特别是我想使用控制器/动作语法而不是标准URL来设置Zend表单的动作URL
$form = new Zend_Form;
$form->setMethod('post')->setAction( $this->url(array('controller' => 'comments', 'action' => 'add')) );
Run Code Online (Sandbox Code Playgroud)
Fer*_*yer 23
有一个动作助手:Zend_Controller_Action_Helper_Url.在动作控制器内部,您可以使用以下命令访问它:
$this->_helper->url($action [, $controller [, $module [, $params]]]);
Run Code Online (Sandbox Code Playgroud)
要么:
$this->_helper->url->url(array(...));
Run Code Online (Sandbox Code Playgroud)
或者,您也可以使用视图助手:
$this->view->url(...);
Run Code Online (Sandbox Code Playgroud)