Skip to content

Instantly share code, notes, and snippets.

@makasim
Created July 15, 2011 09:31
Show Gist options
  • Save makasim/1084388 to your computer and use it in GitHub Desktop.
Save makasim/1084388 to your computer and use it in GitHub Desktop.
how to add custom action for selected ids in WhiteOctoberAdminBundle
<?php
class ArticleAdmin extends DoctrineORMAdmin
{
protected function configure()
{
// this clouse will be called
$batchActions['approve'] = function($selected, $container, $batchAction) {
var_dump($selected);
};
$batchCollection = new BatchActionCollection();
$batchCollection->get('batch')->setOption('actions', $batchActions);
$this
->setName('Articles')
->setDataClass('Rj\\BlogBundle\\Entity\Article')
->addFields(array('title', 'authorName', 'creationTime'))
->addAction($batchCollection)
// you need jquery enabled for the plugin. in my case it is done in layout
->setBaseTemplate('CoreBundle:Layout:default.html.twig')
->setActionOption('doctrine.orm.list', 'batch', true)
->setActionOption('doctrine.orm.list', 'batch_actions', array('approve' => 'Approve'))
;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment