Url view helper gives urls that doesn't work when using index as action #2503

Closed
zfbot opened this Issue Sep 28, 2012 · 5 comments

4 participants

@zfbot

Jira Information

Original Issue: ZF2-407
Issue Type: Bug
Reporter: Mats Svensson
Created: 07/18/12
Assignee: DASPRiD
Components: Zend\Mvc\Router

Description

Or it may be the other way around, that these routes should work but doesn't. Anyhow, there is a mismatch between the view helper and the route resolver.
See my SO post here, where I encounter the issue: http://stackoverflow.com/q/11536962/923847

I have a route like this:

'xmlcoverage' => array(
        'type'    => 'segment',
        'options' => array(
                'route' => '/xml/coverage[/:action][/:id]',
                'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'id'     => '[0-9]+',
                ),
                'defaults' => array(
                        'controller' => 'modulename/xmlcoverage',
                        'action'     => 'index',
                ),
        ),
),

I use the url view helper like this:

$this->url('xmlcoverage', array('action' => 'index', 'id' => $someid))

This gives me xml/coverage/33 which crashes. "The requested controller was unable to dispatch the request."
I believe an id after the controller should map to index action, but it does not. But if it does not, at least the url helper
should make the url work, like xml/coverage/index/33

@zfbot

This issue was ported from the ZF2 Jira Issue Tracker at
http://framework.zend.com/issues/browse/ZF2-407

Known GitHub users mentioned in the original message or comment:
@DASPRiD

@Matsemann

I went around this issue with
public function notFoundAction()
{
$view = new ViewModel($this->indexAction());
$view->setTemplate('path/to-template/index.phtml');
return $view;
}

However, I'm no longer experiencing this issue.

@ralphschindler
Zend Framework member

Thanks @Matsemann

@Matsemann

Then you should provide a non-working example in a new issue or this one (and if this one, reopen it).

@Matsemann

Comment removed, what I responded to:

I'm facing the same bug it is not fixed yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment