Issues

ZF-2896: View helper url() should not take into consideration custom params (other than module, controller and action) from current URL .

Issue Type: Improvement Created: 2008-03-17T06:46:25.000+0000 Last Updated: 2008-05-15T03:52:51.000+0000 Status: Resolved Fix version(s): Reporter: Piotr Czachur (zimnyx) Assignee: Michal Minicki (martel) Tags: - Zend_View

Related issues: - ZF-3219

Attachments:

Description

View helper url(): in my opionion reset flag set to false by default is OK but only if preserved params are only: module, controller and action. Generation of new url using some custom params from current URL (customerId, etc...) doesn't make much sense for me.

Example: after browsing page customer/view/customerId/3, I click in menu on url('action' => 'add') and I get this customer/add/customerId/3 ..
This should not happen by default...

Comments

Posted by Wil Sinclair (wil) on 2008-03-25T20:33:29.000+0000

Please categorize/fix as needed.

Posted by Sebastian Krebs (kingcrunch) on 2008-04-10T04:34:01.000+0000

I think in other cases this makes sense: There can be a language or a "skin"-id, which should be carried to over all requests.

Posted by Matthew Weier O'Phinney (matthew) on 2008-05-09T12:44:19.000+0000

Assigning to Martel; Martel, is this related to the changes requested by Andries?

Posted by Michal Minicki (martel) on 2008-05-14T03:11:01.000+0000

It is related, actually. And it should not be happening with the current codebase from the trunk. I'll write a test for it in order to be 100% sure, though.

The fix will be included in 1.6 as you have asked me to revert the changes from 1.5.2, Matthew.

Posted by Michal Minicki (martel) on 2008-05-15T03:52:50.000+0000

Ok, I guess I have misunderstood the issue at first and I think I do this time.

Piotr, you're probably using the default route, which basically means you're using the same route instance to create two distinct URLs. When your route is getting matched it's set a currently matched route and after that it holds matched values to be used on url creation (named assembling in ZF terms). You have two options here:

  1. Fine-tune you're routing schema
  2. Reset default route when creating "new" URL

Ad. 1: This means you can create two distinct routes to handle your application - one for customer viewing and second for adding: '/customer/:action/:id' (which will handle 'customer/edit/1' as well as 'customer/view/1') and '/customer/add'. Then you just use a named route in the url helper. And switching 'action' on first one will work as you expect it to.

Ad. 2: You have an option to reset the route to it's clean state (which just acts like telling the framework 'I need a NEW, clean route here'). But with that option you will have to supply controller parameter instead of supplying action only.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts