title: Easy admin bundle modal dialog for custom action?
body: <p>I'm working with Easy Admin Bundle for Symfony2. How can I use my own modal dialog with text input for the custom action in the list?</p>
  
  <p>Let's say custom action is called rename and after hitting button Rename in the list I wanna in modal dialog write a new name of something. Then after hitting button OK I wanna call ranameAction in the controller which will do everything needed, but parameter called name must be sent there.</p>
  
  <p>I have the solution but it is not good, there must be some better way.</p>
  
  <p>I created _simple_form.html.twig:</p>
  
  <pre><code>{{
      form(rename_form, {
          action: rename_form.vars.action ~ '&amp;referer=' ~ referer,
          method: 'POST',
          attr: { id: 'rename-form', style: 'display: none' }
      })
  }}
  
  &lt;div id="modal-rename" class="modal fade"&gt;
      &lt;div class="modal-dialog"&gt;
          &lt;div class="modal-content"&gt;
              &lt;div class="modal-body"&gt;
                  &lt;h4&gt;{{ 'rename_modal.title'|trans(_trans_parameters, 'EasyAdminBundle') }}&lt;/h4&gt;
                  &lt;p&gt;{{ 'rename_modal.content'|trans(_trans_parameters, 'EasyAdminBundle') }}&lt;/p&gt;
                  &lt;br /&gt;
                  &lt;input class="form-control" type="text" /&gt;
              &lt;/div&gt;
              &lt;div class="modal-footer"&gt;
                  &lt;button type="button" data-dismiss="modal" class="btn"&gt;
                      {{ 'action.cancel'|trans(_trans_parameters, _translation_domain) }}
                  &lt;/button&gt;
  
                  {% if easyadmin_action_is_enabled(view, 'rename', _entity_config.name) %}
                      {% set _rename_action = easyadmin_get_action(view, 'rename', _entity_config.name) %}
                      &lt;button type="button" data-dismiss="modal" class="btn btn-danger" id="modal-rename-button" formtarget="{{ _rename_action.target }}"&gt;
                          {% if _rename_action.icon %}&lt;i class="fa fa-{{ _rename_action.icon }}"&gt;&lt;/i&gt;{% endif %}
                          {{ 'rename_modal.action'|trans(_trans_parameters, 'EasyAdminBundle') }}
                      &lt;/button&gt;
                  {% endif %}
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In config.yml is a new option:</p>
  
  <pre><code>list:
                  actions:
                      rename:    { name: rename,    type: method, label: 'Rename', css_class: 'btn btn-primary', icon: pencil }
  </code></pre>
  
  <p>In list.html.twig which I'm using:</p>
  
  <pre><code>{% block main %}
  
  {% block rename_form %}
          {% set referer = paginator.currentPage == paginator.nbPages and 1 != paginator.currentPage and 1 == paginator.currentPageResults.count
              ? path('easyadmin', app.request.query|merge({ page: app.request.query.get('page') - 1 }))
              : app.request.requestUri
          %}
  
          {{ include('@EasyAdmin/default/includes/_simple_form.html.twig', {
              view: 'list',
              referer: referer|url_encode,
              rename_form: rename_form_template,
              _translation_domain: _entity_config.translation_domain,
              _trans_parameters: _trans_parameters,
              _entity_config: _entity_config,
          }, with_context = false) }}
      {% endblock rename_form %}    
  {% endblock %}
  
  {% block body_javascript %}
      {{ parent() }}
      &lt;script type="text/javascript"&gt;
      $(function() {
          $('#modal-rename-button').on('click', function(e) {
              e.preventDefault();
  
              var name = $('#name').val();
  
              var renameForm = $('#rename-form');
                      renameForm.attr('action', renameForm.attr('action').replace('__name__', name));
          });
  
          $('a.action-rename').on('click', function(e) {
              e.preventDefault();
              var id = $(this).parents('tr').first().data('id');
  
              $('#modal-rename').modal({ backdrop: true, keyboard: true })
                  .off('click', '#modal-rename-button')
                  .on('click', '#modal-rename-button', function () {
                      var renameForm = $('#rename-form');
                      renameForm.attr('action', renameForm.attr('action').replace('__id__', id));
                      renameForm.trigger('submit');
                  });
          });
      });
  &lt;/script&gt;
  {% endblock %}
  </code></pre>
  
  <p>And finally controller:</p>
  
  <pre><code>protected function createRenameForm($entityName, $entityId, $name)
      {
          $formBuilder = $this-&gt;get('form.factory')-&gt;createNamedBuilder('rename_form')
              -&gt;setAction($this-&gt;generateUrl('easyadmin', array('action' =&gt; 'rename', 'entity' =&gt; $entityName, 'id' =&gt; $entityId, 'name' =&gt; $name)))
              -&gt;setMethod('POST')
          ;
  
          $formBuilder-&gt;add('submit', LegacyFormHelper::getType('submit'), array('label' =&gt; 'rename_modal.action', 'translation_domain' =&gt; 'EasyAdminBundle'));
          $formBuilder-&gt;add('_easyadmin_rename_flag', LegacyFormHelper::getType('hidden'), array('data' =&gt; '1'));
  
          return $formBuilder-&gt;getForm();
      }
  
      public function listAction() {
          $this-&gt;dispatch(EasyAdminEvents::PRE_LIST);
  
          $fields = $this-&gt;entity['list']['fields'];
          $paginator = $this-&gt;findAll($this-&gt;entity['class'], $this-&gt;request-&gt;query-&gt;get('page', 1), $this-&gt;config['list']['max_results'], $this-&gt;request-&gt;query-&gt;get('sortField'), $this-&gt;request-&gt;query-&gt;get('sortDirection'), $this-&gt;entity['list']['dql_filter']);
  
          $this-&gt;dispatch(EasyAdminEvents::POST_LIST, array('paginator' =&gt; $paginator));
  
          return $this-&gt;render($this-&gt;entity['templates']['list'], array(
              'title' =&gt; 'Branches',
              'entity' =&gt; $this-&gt;entity['name'],
              'currentBranch' =&gt; $this-&gt;repo-&gt;getCurrentBranchName(),
              'paginator' =&gt; $paginator,
              'fields' =&gt; $fields,
              'delete_form_template' =&gt; $this-&gt;createDeleteForm($this-&gt;entity['name'], '__id__')-&gt;createView(),
              'rename_form_template' =&gt; $this-&gt;createRenameForm($this-&gt;entity['name'], '__id__', '__name__')-&gt;createView(),
          ));
      }
  </code></pre>