zend 2: Setting a route param via the url() helper is being overwritten by the default set in the config

StackOverflow https://stackoverflow.com/questions/22481557

  •  16-06-2023
  •  | 
  •  

Question

I have a 3 part URL and I am using the url() helper to set the params in my template like this:

<a href="<?php echo $this->escapeHtml($this->url('helpdesk/tickets', array(
    'ticketStatus' => 'closed','group' => abcde))); ?>">View closed tickets</a>

The 'ticketStatus' param is either not being set at all or is being overridden by the default set in the route config (not sure why its not getting set correctly). The 'group' param is getting set correctly though.

Here is the router section of my module.config.php:

'router' => array(
    'routes' => array(
        'helpdesk' => array(
            'type' => 'literal',
            'options' => array(
                'route' => '/helpdesk',
                'defaults' => array(
                    'controller' => 'Helpdesk\Controller\Helpdesk',
                    'action' => 'index',
                ),
            ),
            'may_terminate' => true,
            'child_routes' => array(
                'tickets' => array(
                    'type' => 'segment',
                    'options' => array(
                        'route' => '/tickets/:ticketStatus/:group',
                        'defaults' => array(
                            'action' => 'tickets',
                            'group' => '',
                            'ticketStatus' => '',
                        ),

So when I load the page the url for the anchor is myapp/helpdesk/tickets//abcde.

Whats happening? Why is the url() helper not setting this param?

Was it helpful?

Solution

try this : '/tickets[/:ticketStatus][/:group]'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top