title: Creating batch action on sonata admin
body: <p>I'm trying to add new batch action on Sonata admin. But when i implement example on <a href="http://sonata-project.org/" rel="nofollow">Sonata-Project</a> to my project, it says:</p>
  
  <blockquote>
    <p>Notice: Undefined index: translation_domain</p>
  </blockquote>
  
  <p>How to solve it?</p>
  
  <p>Some code pieces:</p>
  
  <p>AdminClass.php</p>
  
  <pre><code>&lt;?php
  use Sonata\AdminBundle\Admin\Admin;
  
  class AdminClass extends Admin {
      //Other variables, functions
      public function getBatchActions() {
          // retrieve the default batch actions (currently only delete)
          $actions = parent::getBatchActions();
          if (
            $this-&gt;hasRoute('edit') &amp;&amp; $this-&gt;isGranted('EDIT') &amp;&amp;
            $this-&gt;hasRoute('delete') &amp;&amp; $this-&gt;isGranted('DELETE')
          ) {
              $actions['merge'] = array(
                  'label' =&gt; 'Мэйл илгээх',
                  'ask_confirmation' =&gt; true
              );
  
          }
  
          return $actions;
      }
  
      /*protected function configureRoutes(RouteCollection $collection) {
          $collection-&gt;add('sendAction');
          $collection-&gt;add('send-mail', $this-&gt;getRouterIdParameter().'/send-mail');
      }*/
  }
  </code></pre>
  
  <p>CRUDController.php</p>
  
  <pre><code>&lt;?php
  
  use Sonata\AdminBundle\Controller\CRUDController as BaseController;
  use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
  use Symfony\Component\HttpFoundation\RedirectResponse;
  use Symfony\Component\Security\Core\Exception\AccessDeniedException;
  
  class CRUDController extends BaseController
  {
      /**
       * @param ProxyQueryInterface $selectedModelQuery
       * @param Request             $request
       *
       * @return RedirectResponse
       */
      public function batchActionMerge(ProxyQueryInterface $selectedModelQuery)
      {
          if ($this-&gt;admin-&gt;isGranted('EDIT') === false || $this-&gt;admin-&gt;isGranted('DELETE') === false)
          {
              throw new AccessDeniedException();
          }
  
          $request = $this-&gt;get('request');
          $modelManager = $this-&gt;admin-&gt;getModelManager();
  
          $target = $modelManager-&gt;find($this-&gt;admin-&gt;getClass(), $request-&gt;get('targetId'));
  
          if( $target === null){
              $this-&gt;get('session')-&gt;setFlash('sonata_flash_info', 'flash_batch_merge_no_target');
  
              return new RedirectResponse($this-&gt;admin-&gt;generateUrl('list', array('filter' =&gt; $this-&gt;admin-&gt;getFilterParameters())));
          }
  
          $selectedModels = $selectedModelQuery-&gt;execute();
  
          // do the merge work here
  
          try {
              foreach ($selectedModels as $selectedModel) {
                  $modelManager-&gt;delete($selectedModel);
              }
  
              $modelManager-&gt;update($selectedModel);
          } catch (\Exception $e) {
              $this-&gt;get('session')-&gt;setFlash('sonata_flash_error', 'flash_batch_merge_error');
  
              return new RedirectResponse($this-&gt;admin-&gt;generateUrl('list', array('filter' =&gt; $this-&gt;admin-&gt;getFilterParameters())));
          }
  
          $this-&gt;get('session')-&gt;setFlash('sonata_flash_success', 'flash_batch_merge_success');
  
          return new RedirectResponse($this-&gt;admin-&gt;generateUrl('list', array('filter' =&gt; $this-&gt;admin-&gt;getFilterParameters())));
      }
  }
  </code></pre>
  
  <h1>EDIT</h1>
  
  <p>Trying to set values from another entity class on ManyToMany field. But it says the array must be type of Entity.</p>
  
  <p>CRUDController.php</p>
  
  <pre><code>public function batchActionSend(ProxyQueryInterface $selectedModelQuery) {
          ...
          $request = $this-&gt;get('request');
          $modelManager = $this-&gt;admin-&gt;getModelManager();
          $selectedModels = $selectedModelQuery-&gt;execute();
  
          return new RedirectResponse($this-&gt;container-&gt;get('router')-&gt;generate('route_name', array('mails' =&gt; $selectedModels)));
      }
  </code></pre>
  
  <p>AdminClass.php</p>
  
  <pre><code>public function getNewInstance() {
      $instance = parent::getNewInstance();
      $mailadds = $this-&gt;getRequest()-&gt;query-&gt;get('mails');
      foreach ($mailadds as $mailadd) {
          $instance-&gt;addRecipient($mailadd);
      }
  
      return $instance;
  }
  protected function configureFormFields(FormMapper $formMapper) {
          $formMapper
            -&gt;add('recipients', 'sonata_type_model', array('label' =&gt; 'Хүлээн авагчид', 'multiple' =&gt; true, 'by_reference' =&gt; false)
  ...
  }
  </code></pre>
  
  <blockquote>
    <p>Note: recipients is ManyToMany field.</p>
  </blockquote>