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

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

Please categorize/fix as needed.

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.

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

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.

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.