Skip to content

Commit bca6861

Browse files
committed
Add a body hookable to the create/update content composition
Tabler's header-to-content spacing comes from .page-body's top margin against its .page-header sibling. The create/update pages render no .page-body, so the form card sits glued to the sticky header. BC break: form_error_alert and form move from …content.* to …content.body.*.
1 parent 3431d89 commit bca6861

5 files changed

Lines changed: 55 additions & 6 deletions

File tree

UPGRADE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# UPGRADE
2+
3+
## Unreleased
4+
5+
### BootstrapAdminUi
6+
7+
* The create/update content composition gained a `body` hookable that renders
8+
the Tabler `.page-body` wrapper. The `form_error_alert` and `form` hookables
9+
moved inside it:
10+
11+
| Before | After |
12+
|---|---|
13+
| `sylius_admin.common.create.content.form_error_alert` | `sylius_admin.common.create.content.body.form_error_alert` |
14+
| `sylius_admin.common.create.content.form` | `sylius_admin.common.create.content.body.form` |
15+
| `sylius_admin.common.update.content.form_error_alert` | `sylius_admin.common.update.content.body.form_error_alert` |
16+
| `sylius_admin.common.update.content.form` | `sylius_admin.common.update.content.body.form` |
17+
18+
Hook configuration and templates targeting these hookables or their children
19+
(e.g. `…content.form.sections.general`) must be retargeted accordingly. Apps
20+
that overrode `shared/crud/common/content/form.html.twig` to add the missing
21+
`.page-body` themselves should drop that override to avoid double wrapping.

src/BootstrapAdminUi/config/app/twig_hooks/common/create.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
'header' => [
5555
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/header.html.twig',
5656
],
57+
'body' => [
58+
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/body.html.twig',
59+
],
60+
],
61+
62+
'sylius_admin.common.create.content.body' => [
5763
'form_error_alert' => [
5864
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form_error_alert.html.twig',
5965
],
@@ -89,19 +95,19 @@
8995
],
9096
],
9197

92-
'sylius_admin.common.create.content.form' => [
98+
'sylius_admin.common.create.content.body.form' => [
9399
'sections' => [
94100
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections.html.twig',
95101
],
96102
],
97103

98-
'sylius_admin.common.create.content.form.sections' => [
104+
'sylius_admin.common.create.content.body.form.sections' => [
99105
'general' => [
100106
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections/general.html.twig',
101107
],
102108
],
103109

104-
'sylius_admin.common.create.content.form.sections.general' => [
110+
'sylius_admin.common.create.content.body.form.sections.general' => [
105111
'default' => [
106112
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections/general/default.html.twig',
107113
],

src/BootstrapAdminUi/config/app/twig_hooks/common/update.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
'header' => [
5555
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/header.html.twig',
5656
],
57+
'body' => [
58+
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/body.html.twig',
59+
],
60+
],
61+
62+
'sylius_admin.common.update.content.body' => [
5763
'form_error_alert' => [
5864
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form_error_alert.html.twig',
5965
],
@@ -91,19 +97,19 @@
9197
],
9298
],
9399

94-
'sylius_admin.common.update.content.form' => [
100+
'sylius_admin.common.update.content.body.form' => [
95101
'sections' => [
96102
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections.html.twig',
97103
],
98104
],
99105

100-
'sylius_admin.common.update.content.form.sections' => [
106+
'sylius_admin.common.update.content.body.form.sections' => [
101107
'general' => [
102108
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections/general.html.twig',
103109
],
104110
],
105111

106-
'sylius_admin.common.update.content.form.sections.general' => [
112+
'sylius_admin.common.update.content.body.form.sections.general' => [
107113
'default' => [
108114
'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections/general/default.html.twig',
109115
],
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="page-body">
2+
{% hook 'body' %}
3+
</div>

src/BootstrapAdminUi/tests/Functional/TemplatesTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,17 @@ public function testIndexTemplate(): void
3838
$this->assertAnySelectorTextSame('.nav-link-title', 'Dashboard'); // with "messages" domain
3939
$this->assertAnySelectorTextSame('.nav-link-title', 'Library'); // with "menu" domain
4040
}
41+
42+
public function testCreateTemplatePageStructure(): void
43+
{
44+
$this->client->request('GET', '/books/new');
45+
46+
$this->assertResponseIsSuccessful();
47+
// Tabler layout: .page-body must be the .page-header's sibling — its
48+
// top margin provides the header-to-content spacing.
49+
$this->assertSelectorExists('.page-wrapper > .page-header');
50+
$this->assertSelectorExists('.page-header + .page-body');
51+
$this->assertSelectorExists('.page-body form');
52+
$this->assertSelectorExists('.page-body form input[name="book_resource[name]"]');
53+
}
4154
}

0 commit comments

Comments
 (0)