Zend framework2 Zend Framework 2 url帮助程序
我想知道为什么没有显示id参数。生成的URL为:“”,但我预期为“”。我错过了什么 控制器代码:Zend framework2 Zend Framework 2 url帮助程序,zend-framework2,Zend Framework2,我想知道为什么没有显示id参数。生成的URL为:“”,但我预期为“”。我错过了什么 控制器代码: echo "<a href='" . $this->url('home', array('action' => 'editroom', 'id' => $room->getId())) . "' title='Bearbeiten des Eintrags'>Bearbeiten</a>;"; echo“; 您可能没有在起始路线中定义id参数。您需要
echo "<a href='" . $this->url('home', array('action' => 'editroom', 'id' => $room->getId())) . "' title='Bearbeiten des Eintrags'>Bearbeiten</a>;";
echo“;
您可能没有在起始路线中定义id参数。您需要添加子管线以允许其他参数:
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/[:controller[/[:action]]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Application\Controller\IndexController',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'wildcard' => array(
'type' => 'Zend\Mvc\Router\Http\Wildcard',
'options' => array(
'key_value_delimiter' => '/',
'param_delimiter' => '/',
),
),
),
)
然后你这样称呼它:
echo "<a href='" . $this->url('home/wildcard', array('action' => 'editroom', 'id' => $room->getId())) . "' title='Bearbeiten des Eintrags'>Bearbeiten</a>;";
echo“;
@sroes感谢您的建议。我混合了路由的名称,路由的名称是editroom而不是home-:-)正如我已经提到的,我混合了路由的名称。感谢您的帮助@sroes!