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:
- 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.
- Otherwise, think that this should be reflected in the documentation, and especially in the Jobeet tutorial.