Skip to content

Commit 8b5c837

Browse files
authored
fix ImmutableArrayType field helper message must not displayed twice introduced in (#8329) and tests immutable array field and subfields help message (#8334)
1 parent 8ee6c72 commit 8b5c837

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

src/Resources/views/Form/form_admin_fields.html.twig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,6 @@ file that was distributed with this source code.
416416

417417
{% block sonata_type_immutable_array_widget %}
418418
<div {{ block('widget_container_attributes') }}>
419-
{{ form_help(form) }}
420-
421419
{% for key, child in form %}
422420
{{ block('sonata_type_immutable_array_widget_row') }}
423421
{% endfor %}

tests/App/Admin/FooAdmin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function configureFormFields(FormMapper $form): void
7575
'elements',
7676
ImmutableArrayType::class,
7777
[
78-
'help' => 'elements help message',
78+
'help' => 'Elements main field help message',
7979
'error_bubbling' => false,
8080
'constraints' => [
8181
new Collection([
@@ -91,7 +91,7 @@ protected function configureFormFields(FormMapper $form): void
9191
'elements_item',
9292
TextType::class,
9393
[
94-
'help' => 'elements_item help message',
94+
'help' => 'Elements sub field help message',
9595
],
9696
],
9797
],

tests/Functional/Controller/CRUDControllerTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,36 @@ public function testCollectionErrorMessageIsDisplayOnce(): void
7676
);
7777
}
7878

79+
/**
80+
* @see https://github.com/sonata-project/SonataAdminBundle/issues/8328
81+
*/
82+
public function testImmutableArrayHelpAttributeIsDisplayed(): void
83+
{
84+
$client = static::createClient();
85+
$crawler = $client->request(Request::METHOD_GET, '/admin/tests/app/foo/create');
86+
87+
static::assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode());
88+
static::assertCount(
89+
1,
90+
$crawler->filter('.help-block.sonata-ba-field-help:contains("Elements main field help message")')
91+
);
92+
}
93+
94+
/**
95+
* @see https://github.com/sonata-project/SonataAdminBundle/issues/8328
96+
*/
97+
public function testImmutableArrayKeysItemHelpAttributeAreDisplayed(): void
98+
{
99+
$client = static::createClient();
100+
$crawler = $client->request(Request::METHOD_GET, '/admin/tests/app/foo/create');
101+
102+
static::assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode());
103+
static::assertCount(
104+
1,
105+
$crawler->filter('.help-block.sonata-ba-field-help:contains("Elements sub field help message")')
106+
);
107+
}
108+
79109
/**
80110
* https://github.com/sonata-project/SonataAdminBundle/issues/6904.
81111
*/

0 commit comments

Comments
 (0)