diff --git a/assets/css/easyadmin-theme/datagrids.css b/assets/css/easyadmin-theme/datagrids.css
index 6dd3aff2ec..ef6bc3c02f 100644
--- a/assets/css/easyadmin-theme/datagrids.css
+++ b/assets/css/easyadmin-theme/datagrids.css
@@ -145,13 +145,29 @@ table.datagrid:not(.datagrid-empty) tr:not(.empty-row) td.actions.actions-as-dro
.datagrid td.actions {
text-align: right;
}
-.datagrid td.actions a:not(.dropdown-item) {
+.datagrid td.actions a:not(.dropdown-item),
+.datagrid td.actions form:not(.dropdown-item) {
font-size: var(--font-size-sm);
font-weight: 500;
}
-.datagrid td.actions a:not(.dropdown-item) + a:not(.dropdown-item) {
+
+.datagrid td.actions form:not(.dropdown-item) {
+ display: inline-block;
+ color: var(--link-color);
+}
+
+.datagrid td.actions form:not(.dropdown-item) button {
+ all: unset;
+ cursor: pointer;
+ width: 100%;
+}
+
+.datagrid td.actions a:not(.dropdown-item) + a:not(.dropdown-item),
+.datagrid td.actions form:not(.dropdown-item) + a:not(.dropdown-item),
+.datagrid td.actions a:not(.dropdown-item) + form:not(.dropdown-item) {
margin-inline-start: 10px;
}
+
.datagrid td.actions a:not(.dropdown-item) .action-icon {
font-size: var(--font-size-base);
margin-inline-end: 2px;
@@ -205,6 +221,13 @@ table.datagrid:not(.datagrid-empty) tr:not(.empty-row) td.actions.actions-as-dro
.datagrid .dropdown-actions .dropdown-menu { z-index: var(--zindex-900); }
+.datagrid .dropdown-actions .dropdown-menu form button.action-button {
+ all: unset;
+ cursor: pointer;
+ width: 100%;
+}
+
+
.datagrid .ea-lightbox-thumbnail img {
background: var(--white);
border: 1px solid transparent;
diff --git a/templates/components/ActionMenu/ActionList/Item.html.twig b/templates/components/ActionMenu/ActionList/Item.html.twig
index 8b7372e3a9..f10c002690 100644
--- a/templates/components/ActionMenu/ActionList/Item.html.twig
+++ b/templates/components/ActionMenu/ActionList/Item.html.twig
@@ -4,11 +4,25 @@
icon = null,
url = null,
htmlAttributes = {},
+ type = "a",
+ name = ""
%}
+ {% if type == "form" %}
+ {%- set form_id = 'form-' ~ name ~ '-' ~ random() -%}
+
+ {% else %}
{%- if icon %} {% endif -%}
{%- if label is not empty -%}{{ renderLabelRaw ? label|raw : label }}{%- endif -%}
+ {% endif %}
diff --git a/templates/crud/index.html.twig b/templates/crud/index.html.twig
index 1145367579..b83469b7d3 100644
--- a/templates/crud/index.html.twig
+++ b/templates/crud/index.html.twig
@@ -172,7 +172,9 @@
class="{{ action.cssClass }}" url="{{ action.linkUrl }}"
icon="{{ action.icon }}" icon:class="action-icon"
htmlAttributes="{{ action.htmlAttributes }}"
- label="{{ action.label|trans }}" label:class="action-label" renderLabelRaw />
+ label="{{ action.label|trans }}" label:class="action-label" renderLabelRaw
+ type="{{ 'form' == action.htmlElement ? 'form' : 'a' }}"
+ name="{{ action.name }}"/>
{% endfor %}
diff --git a/tests/Controller/ActionsCrudControllerTest.php b/tests/Controller/ActionsCrudControllerTest.php
index 7373db8880..cfca8801aa 100644
--- a/tests/Controller/ActionsCrudControllerTest.php
+++ b/tests/Controller/ActionsCrudControllerTest.php
@@ -60,5 +60,10 @@ public function testFormAction()
static::assertCount(1, $crawler->filter('form[id^="form-action9-"]'));
static::assertCount(1, $crawler->filter('form[id^="form-action9-"] > .btn'));
static::assertSame('POST', $crawler->filter('form[id^="form-action9-"]')->attr('method'));
+
+ // use of 20 as there will be 1 on each of the line => by default 20 as defined in EasyAdminBundle\Config\Crud
+ static::assertCount(20, $crawler->filter('form[id^="form-action_form_entity-"]'), 'There is no Action Entity form in the dropdown');
+ static::assertCount(20, $crawler->filter('form[id^="form-action_form_entity-"] > button', 'There is no Action Entity form button in the dropdown'));
+ static::assertSame('POST', $crawler->filter('form[id^="form-action_form_entity-"]')->attr('method'), 'The method of the Action Entity form is not POST');
}
}
diff --git a/tests/Controller/InlineActionsCrudControllerTest.php b/tests/Controller/InlineActionsCrudControllerTest.php
new file mode 100644
index 0000000000..43444c7073
--- /dev/null
+++ b/tests/Controller/InlineActionsCrudControllerTest.php
@@ -0,0 +1,51 @@
+client->followRedirects();
+ $this->client->setServerParameters(['PHP_AUTH_USER' => 'admin', 'PHP_AUTH_PW' => '1234']);
+
+ $this->categories = $this->entityManager->getRepository(Category::class);
+ }
+
+ public function testCssClasses(): void
+ {
+ $crawler = $this->client->request('GET', $this->generateIndexUrl());
+
+ // TODO : see how to test the presence of the form into the inline actions
+ }
+
+ public function testFormAction(): void
+ {
+ $crawler = $this->client->request('GET', $this->generateIndexUrl());
+
+ // use of 20 as there will be 1 on each of the line => by default 20 as defined in EasyAdminBundle\Config\Crud
+ $nbEntitiesPerPage = 20;
+ static::assertCount($nbEntitiesPerPage, $crawler->filter('form[id^="form-action_form_entity-"]'));
+ static::assertCount($nbEntitiesPerPage, $crawler->filter('form[id^="form-action_form_entity-"] > button'));
+ static::assertSame('POST', $crawler->filter('form[id^="form-action_form_entity-"]')->attr('method'));
+ }
+}
diff --git a/tests/TestApplication/src/Controller/ActionsCrudController.php b/tests/TestApplication/src/Controller/ActionsCrudController.php
index 1c4d7d512d..7b172e29eb 100644
--- a/tests/TestApplication/src/Controller/ActionsCrudController.php
+++ b/tests/TestApplication/src/Controller/ActionsCrudController.php
@@ -45,6 +45,9 @@ public function configureActions(Actions $actions): Actions
$action9 = Action::new('action9')->linkToCrudAction('')->createAsGlobalAction()->displayAsForm();
+ // this tests the existence of the form action in an entity action
+ $actionFormEntity = Action::new('action_form_entity')->linkToCrudAction('')->displayAsForm();
+
return $actions
->add(Crud::PAGE_INDEX, $action1)
->add(Crud::PAGE_INDEX, $action2)
@@ -55,6 +58,7 @@ public function configureActions(Actions $actions): Actions
->add(Crud::PAGE_INDEX, $action7)
->add(Crud::PAGE_INDEX, $action8)
->add(Crud::PAGE_INDEX, $action9)
+ ->add(Crud::PAGE_INDEX, $actionFormEntity)
->update(Crud::PAGE_INDEX, Action::NEW, function (Action $action) {
return $action->setIcon('fa fa-fw fa-plus')->setLabel(false);
})
diff --git a/tests/TestApplication/src/Controller/InlineActionsCrudController.php b/tests/TestApplication/src/Controller/InlineActionsCrudController.php
new file mode 100644
index 0000000000..252a61b0a9
--- /dev/null
+++ b/tests/TestApplication/src/Controller/InlineActionsCrudController.php
@@ -0,0 +1,45 @@
+showEntityActionsInlined(true)
+ ;
+ }
+
+ public function configureFields(string $pageName): iterable
+ {
+ return [
+ TextField::new('name'),
+ ];
+ }
+
+ public function configureActions(Actions $actions): Actions
+ {
+ // this tests the existence of the form action in an entity action
+ $actionFormEntity = Action::new('action_form_entity')->linkToCrudAction('')->displayAsForm();
+
+ return $actions
+ ->add(Crud::PAGE_INDEX, $actionFormEntity)
+ ;
+ }
+}