Zend/Route with parent child format not working for view helper $this->url() in expected way

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend/Route with parent child format not working for view helper $this->url() in expected way

gunytalk
I configured a route task in module.configure as follows

    'router' => array(
                    'routes' => array(
                            'task' => array(
                                    'type'    => 'Segment',
                                    'options' => array(
                                            'route'    => '/task[/:action[/:id]]',
                                            'defaults' => array(
                                                    '__NAMESPACE__' => 'Checklist\Controller',
                                                    'controller'    => 'Task',
                                                    'action'        => 'index',
                                            ),
                                            'constraints' => array(
                                                    'action' => '^add|edit|delete$',
                                                    'id'     => '[0-9]+',
                                            ),
                                    ),
                            ),
                    ),
            ),

 echo $this->url('task', array('action'=>'add')) will return /task/add
What i want is to define the route in parent-child format
i slitely alter the code in module.config.php to make it as parent-child format as follows


    'task' => array(
                    'type'    => 'Literal',
                    'options' => array(
                        'route'    => '/task',
                        'defaults' => array(
                            '__NAMESPACE__' => 'Checklist\Controller',
                            'controller'    => 'Task',
                            'action'        => 'index',
                        ),
                    ),
                    'may_terminate' => true,
                    'child_routes' => array(
                        'default' => array(
                            'type'    => 'Segment',
                            'options' => array(
                               'route'    => '[/:action]',
                               
                                'constraints' => array(
                                    'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                                ),
                                'defaults' => array(
                               
                                ),
                            ),
                        ),
                    ),
                ),
            ),

but in my view file when echo $this->url('task', array('action'=>'add'))  returns only /task instead of /task/add
By giving direct url say tasklist/task/add is accessible form the browser
How to configure route in parent -child format to get /task/add by echo $this->url('task',array('action'=>'add'))
Reply | Threaded
Open this post in threaded view
|

Re: Zend/Route with parent child format not working for view helper $this->url() in expected way

Stefano Torresi
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Zend/Route with parent child format not working for view helper $this->url() in expected way

gunytalk
Great :) Thank you and it worked!

i thought the default thing  will be taken as granted as it is default
Reply | Threaded
Open this post in threaded view
|

Re: Zend/Route with parent child format not working for view helper $this->url() in expected way

Stefano Torresi
CONTENTS DELETED
The author has deleted this message.