0

For my need, I'm planning to add a custom column to a entity list. I've written this inside the configureListFields :

->add('_action', 'actions', array(
            'actions' => array(
                'code' => array('template' => 'BOBAdminBundle:test:custom.html.twig'),
            )
        ))

My twig :

<img src="{{ asset('bundles/sonataadmin/famfamfam/delete.png') }}"  />

It works. Problem : I don't know why :S, since I've just copy/paste the code from somewhere. I figured out than the '_action' determined the name of the column. But what if I want to change it ? Where does this 'actions' name come from ? Where can I change it ?

1 Answers1

0

The _action is used to add custom actions for the list items. Like edit and delete which are set by default. Here is a full documentation:

List actions

You can set actions for the list items by adding an ‘_action’ field in configureListFields:

<?php
    $listMapper->add('_action', 'actions', array(
    'actions' => array(
        'view' => array(),
        'edit' => array(),
    )
))

Edit and delete actions are enabled in the default configuration. You can add your own! Default template file is: *SonataAdminBundle:CRUD:list_action[ACTION_NAME].html.twig*

You can specify your own by setting up the ‘template’ option like so:

<?php
$listMapper->add('_action', 'actions', array(
    'actions' => array(
        'view' => array(),
        'edit' => array(),
        'delete' => array('template' => 'MyBundle:MyController:my_partial.html.twig'),
    )
))
Turdaliev Nursultan
  • 2,538
  • 1
  • 22
  • 28