Development

#6557 (Incorrect request method for admin generator list actions)

You must first sign up to be able to contribute.

Ticket #6557 (new defect)

Opened 8 months ago

Incorrect request method for admin generator list actions

Reported by: aboks Assigned to: fabien
Priority: minor Milestone:
Component: generator Version: 1.2.7
Keywords: admin generator route method list actions Cc:
Qualification: Unreviewed

Description

When trying to use a custom list action in the admin generator, I run into 404 errors. In my routing.yml I have:

  ...
  class: sfDoctrineRouteCollection
  options:
    ...
    column:               id
    with_wildcard_routes: true
  ...

I don't have a default /:module/:action/*-route.

If I now use in my generator.yml

...
list:
  actions:
    custom: 
      label: Custom action
...

I get a 404 error when clicking the link below the list. It seems that I need to change this snippet to

...
list:
  actions:
    custom: 
      label: Custom action
      params: {method: post}
...

in order to let the request match the *_collection-route (which requires the POST-method) and get my action executed.

This is strange, since I didn't remember having to do this in the Jobeet tutorial. Debugging a little in my Jobeet project, I found out that the link to the deleteNeverActivated-action does not match the jobeet_job_collection-route as expected, but the default route (which coincidentally leads to the correct action). This also means that deleteNeverActivated is actually a GET action, which in my opinion violates REST.

I think there are two different solutions to this problem:

  1. Make POST the default method for list actions in generator.yml, so it doesn't have to be set explicitly. I think this is the best solution, as the *_collection-route is meant to be used for these actions and that route requires POST.
  2. Otherwise, think that this should be reflected in the documentation, and especially in the Jobeet tutorial.

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.