views:

27

answers:

1

I am learning Symfony and I'm working with the following URI:

url_for('newItem/show?id='.$item->getId().'&name='.$item->getName().'&summary='.$item->getSummary())

With the below routing.yml

item_show_user:
  url:   /newItem/:name/:summary
  param: {module: newItem, action: show} 

# default rules

homepage:
  url:   /
  param: { module: newItem, action: index }

default_index:
  url:   /:module
  param: { action: index }

default:
  url:   /:module/:action/*

Based on the parameters of the URI the route it should use is 'item_show_user', is this correct? Instead I am getting a 404 error.

Strangely if I change all instances of summary, to model (another column in my database) the route works absolutely fine. How can this be?

Furthermore when the URL does work (e.g. using model) the URL should display as:

/newItem/Name/Model

Instead it shows up as:

/newItem/Name/Model/?id=

Can you help me there also?

+1  A: 
item_show_user:
  url:   /newItem/:name/:summary/:id
  param: {module: newItem, action: show} 

You need to put the id param on your route if you want to use item_show_user route.

johnwards
Thanks for that, I actually found this out through experimenting but forgot to come back and mark it as solved.
James