I've posted this 3 times already and cannot seem to see the post don't know what I am doing wrong.
I've created my batch action my my admin class as below:
namespace ACME\MyBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\AdminBundle\Route\RouteCollection;
class JournalistProfileAdmin extends Admin
{
...........
...........
public function getBatchActions()
{
$lists = $this->getModelManager()->createQuery('ACME\MyBundle\Entity\ContactList', 'c')->execute();
$listsArray = array();
foreach ($lists as $list)
{
$listsArray[$list->getId()] = $list->getName();
}
$actions = parent::getBatchActions();
$actions['addToGroup'] = array(
'label' => $this->trans('action_add_to_group', array(), 'SonataAdminBundle'),
'ask_confirmation' => true,
'secondary' => $listsArray,
);
return $actions;
}
}
Then extended the CRUDController as in the file below:
namespace ACME\MyBundle\Controller;
use Sonata\AdminBundle\Controller\CRUDController as Controller;
use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery as ProxyQueryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
class JournalistProfileAdminController extends Controller
{
public function batchActionAddToIsRelevant()
{
return true;
}
public function batchActionAddToGroup(ProxyQueryInterface $selectedModelQuery)
{
........................
...........................
}
When I try to run my batch action, I get Sonata\AdminBundle\Controller\CRUDController::batchActionAddToGroup method must be created error.
Can anyone please help?