Skip to content

Commit

Permalink
document another way to add dashboard action
Browse files Browse the repository at this point in the history
  • Loading branch information
kunicmarko20 authored and greg0ire committed Mar 18, 2018
1 parent a3fef65 commit 67e73a2
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions docs/cookbook/recipe_custom_action.rst
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,34 @@ Create a template for that button:
</li>
You can also add this action to your dashboard actions, you have to overwrite
the ``getDashboardActions`` method in your admin class::
the ``getDashboardActions`` method in your admin class and there are two
ways you can add action::

public function getDashboardActions()
{
$actions = parent::getDashboardActions();

$actions['import']['template'] = 'import_dashboard_button.html.twig';

return $actions;
}

Create a template for that button:

.. code-block:: html+jinja

<a class="btn btn-link btn-flat" href="{{ admin.generateUrl('import') }}">
<i class="fa fa-level-up"></i>{{ 'import_action'|trans({}, 'SonataAdminBundle') }}
</a>
Or you can just pass values as array::

public function getDashboardActions()
{
$actions = parent::getDashboardActions();

$actions['import'] = [
'label' => 'action_import',
'label' => 'import_action',
'translation_domain' => 'SonataAdminBundle',
'url' => $this->generateUrl('import'),
'icon' => 'level-up',
Expand Down

0 comments on commit 67e73a2

Please sign in to comment.