问题
i'm newbie of sonata,
i have a ContentTestAdmin with entity etc, that can only contains 4 record - record 1 - record 2 - record 3 - record 4
i already disabled create and delete function
public function configureRoutes(RouteCollection $collection)
{
$collection->remove('create')->remove('delete');
}
but i need to change link on dashboard and on the left menu:
actually i put on my service.yml
admin.comuni:
class: AppBundle\Admin\ContentTestAdmin
arguments: [~, AppBundle\Entity\ContentTest, ~]
tags:
- { name: sonata.admin, manager_type: orm, label: Content Test, group: Main Section }
and i see on dashboard the box with title "Content" and inside the "Content Test" with link to the list
i would erase this part and see like
Content test - record 1 title > with link to 1/edit - record 2 title > with link to 2/edit - record 3 title > with link to 3/edit - record 4 title > with link to 4/edit
same issue for the left menu, a folder named Content test with 4 link inside
is possible? thank you
回答1:
You should be configuring your admin menu in your app/config.yml.
Here is an example :
sonata_admin:
dashboard:
groups:
content_test:
label: Content
icon: '<i class="fa fa-address-card"></i>'
items:
- route: 'route_to_record1'
route_params: { id: 1 } #id of record 1
label: Record 1
- route: 'route_to_record_2'
route_params: { id: 2 }
label: Record 2
To find out the route to a record execute the command
app/console (bin/console on sf3) debug:router
This will show you all the routes existing in your app just find the route sonata admin generated for your ContentAdmin for show or edit or whatever you need( ex: admin_content_test_show).then just fill route_params with the id of the desired record.
(you can use that to point to any route in your app and prefill any parameters of that route)
Hope you find this helpful
来源:https://stackoverflow.com/questions/41110232/sonata-and-single-page