Child routes are named with the 'parent/child' format, so you're actually
trying to assemble only the parent route 'task', not the child
'task/default'.
To get the correct url you have to call: $this->url('task/default',
array('action'
=> 'add'))

Cheers


2014-04-01 12:15 GMT+02:00 rinireghu <[email protected]>:

> 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'))
>
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/Zend-Route-with-parent-child-format-not-working-for-view-helper-this-url-in-expected-way-tp4661936.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: [email protected]
> Info: http://framework.zend.com/archives
> Unsubscribe: [email protected]
>
>
>

Reply via email to