I had to make an entity called ProfileSchema with some fields, which one is Project_id. I needed to make a List, Edit, New, etc., for which I used the admin generator. The problem was as follows.
I have a list of projects, which they link to the list of the ProfileSchemas that have the same project_id, so I needed a route like: /backend/project/:project_id/ListProfileSchema
I couldn't find a way to do this with the admin generator (getting the project_id into the route), so I coded by hand all the routes (around 12, the new, edit, delete, batch actions, etc.), and change all the code generated by the admin generator to use the project_id passed as a parameter and the code generated by the adming generator as a guide.
==Questions==
Is there a way more simple to do something like this?
Now I need to add the confirmation JavaScript on the delete action on the actions of the list, which is generated by the method linkToDeleteMenu
public function linkToDeleteMenu($object, $params){
$url = url_for('project_delete_profile_schema', array('project_id' => $this->project_id, 'profile_schema_id' => $object->getId() ));
// $url = '/backend/project/1/DeleteProfileSchema/16'
return link_to(__($params['label'], array(), 'sf_admin'), $url, $object, array('confirm' => !empty($params['confirm']) ? __($params['confirm'], array(), 'sf_admin') : $params['confirm'], 'project_id' => $this->project_id, 'profile_schema_id' => $object->getId()));
}
The above code doesn't get the JavaScript. This code below generates the link well and it works, but I can't make the confirmation for the JavaScript appear.
return link_to(__($params['label'], array(), 'sf_admin'), $url, $object);
And the confirmation data is set, as replacing $url with $this->getUrlForAction('delete') does the trick but with the incorrect URL (the one generated by the admin generator).
By the way, I searched a lot trying to find something similar. The only similar question was this:
But the answer didn't help me (as the default value is not dynamic and can't get to override it)