routing is not found

Discussion relating to version 1.3.x and 1.4.x

routing is not found

Postby jstuardo » Sun Aug 15, 2010 4:24 am

Hello... I' m using Symfony 1.4

I have a form that allows a user to change his password. The URL to the form is "backend_dev.php/user/1/changePassword". In order for it to work, I needed to add this route:

Code: Select all
user_change_password:
  url:   /:module/:id/changePassword
  class: sfDoctrineRoute
  param: { module: user }
  options: { model: User, type: object }
  requirements:
    id: \d+


In the form template, I created the form tag this way:

Code: Select all
<?php echo form_tag_for($form, '@user_change_password', array('id'=>'form')) ?>


I created the following route, placed preceeding the user_change_password route:

Code: Select all
user_change_password_update:
  url:   /:module/:id/updatePassword
  class: sfDoctrineRoute
  param: { module: user }
  options: { model: User, type: object }
  requirements:
    id: \d+   


In that case, the form action points correctly to "backend_dev.php/user/1/updatePassword"

When I submit the form, this error occurs: Action "user/1" does not exist.

By seeing the log, I found this entry:

Match route "default" (/:module/:action/*) for /user/1/updatePassword with parameters array ( 'module' => 'user', 'action' => '1', 'updatePassword' => true,)

The question is: why does the default route matchs instead of the user_change_password_update route?

Default route is the last route in the routing.yml file.

Any help will be greatly appreciated

Thanks
Jaime
Symfony 1.4 and 2
jstuardo
Member
 
Posts: 86
Joined: Mon May 03, 2010 3:50 am
Location: Santiago

Re: routing is not found

Postby taylorr » Sun Aug 15, 2010 5:18 am

I think you may insert an "action" in the "param" so it reads like:

module: user, action: changePassword

?
Develop with Symfony, PHP, MySQL
User avatar
taylorr
Member
 
Posts: 47
Joined: Fri Jan 16, 2009 10:08 am
Location: Suzhou, China

Re: routing is not found

Postby jstuardo » Sun Aug 15, 2010 4:46 pm

Hello... I tried it but it did not work.. I have used:

Code: Select all
user_change_password_update:
  url:   /:module/:id/updatePassword
  class: sfDoctrineRoute
  param: { module: user, action: updatePassword }
  options: { model: User, type: object }
  requirements:
    id: \d+   


The most strange thing is that the following route does work when I load the page without submitting a form:

Code: Select all
user_change_password:
  url:   /:module/:id/changePassword
  class: sfDoctrineRoute
  param: { module: user }
  options: { model: User, type: object }
  requirements:
    id: \d+


Any further help will be greatly appreciated.

Thanks
Jaime
Symfony 1.4 and 2
jstuardo
Member
 
Posts: 86
Joined: Mon May 03, 2010 3:50 am
Location: Santiago

Re: routing is not found

Postby wissl » Sun Aug 15, 2010 5:31 pm

That is, because sfDoctrineRoute only matches the sf_method "get" by default. I do not know why that was done, but you have to add "sf_method: [get, post]" to those routes' requirements to get them work properly.
wissl
Faithful Member
 
Posts: 461
Joined: Sun Mar 02, 2008 2:34 pm
Location: Germany

Re: routing is not found

Postby jstuardo » Sun Aug 15, 2010 8:50 pm

Hello... this is my final route definition but the problem still exists:

Code: Select all
user_change_password_update:
  url:   /:module/:id/updatePassword
  class: sfDoctrineRoute
  param: { module: user }
  options: { model: User, type: object }
  requirements:
    id: \d+
    sf_method: [ get, post ]


Any other help?
Thanks

Jaime
Symfony 1.4 and 2
jstuardo
Member
 
Posts: 86
Joined: Mon May 03, 2010 3:50 am
Location: Santiago

Re: routing is not found

Postby wissl » Sun Aug 15, 2010 8:56 pm

Hmmm. "action" is missing in "param"?
wissl
Faithful Member
 
Posts: 461
Joined: Sun Mar 02, 2008 2:34 pm
Location: Germany

Re: routing is not found

Postby jstuardo » Mon Aug 16, 2010 2:08 am

I tried with action in param too, with no success.

Cheers
Jaime
Symfony 1.4 and 2
jstuardo
Member
 
Posts: 86
Joined: Mon May 03, 2010 3:50 am
Location: Santiago

Re: routing is not found

Postby Mowgly » Thu Nov 10, 2011 5:25 pm

No answer for a long time ...
I just encountered the same problem on one of my projects ...

My solution is check the "REAL" method of ur form.
I mean, in my _form partial generated, an abusive and not supported yet by all browsers hidden input field turn method on "put" and not "post" ...

Choose what's good for u : change method in routing rule or change method in hidden field ;)

It's work fin for me now ;)

Hope it helps
++
Mowgly
Junior Member
 
Posts: 1
Joined: Thu Nov 10, 2011 5:18 pm

Re: routing is not found

Postby jocelyndong » Mon Nov 14, 2011 4:32 am

en, i have heard of this problem, and i hope you could sove this problem ASAP.
YangshuoLhasa Tour
jocelyndong
Junior Member
 
Posts: 1
Joined: Mon Nov 14, 2011 4:28 am

Re: routing is not found

Postby bjland4 » Mon Nov 28, 2011 6:15 am

YES! I agree this :"No answer for a long time ...
I just encountered the same problem on one of my projects ...Tibet TravelMy solution is check the "REAL" method of ur form.
I mean, in my _form partial generated, an abusive and not supported yet by all browsers hidden input field turn method on "put" and not "post" ...
Choose what's good for u : change method in routing rule or change method in hidden field "
bjland4
Junior Member
 
Posts: 1
Joined: Mon Nov 28, 2011 6:09 am


Return to symfony 1.3 and 1.4

Who is online

Users browsing this forum: No registered users and 3 guests