Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Oct 29, 2023
1 parent 2065e67 commit 468b8a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/Controller/FormFieldLabelControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testFieldsLabelsInForms()
static::assertSelectorTextSame('label[for="BlogPost_publishedAt"]', 'PublishedAt Lorem Ipsum', 'The "publishedAt" field defines its label as a translatable string with regular text (no HTML contents).');

// fields with a label defined as a string with HTML contents
static::assertSame('<a href="https://example.com">Tab</a> <b>7</b>', trim($crawler->filter('ul.nav-tabs #tablist-tab-tab-7')->html()), 'The "Tab 7" defines its label as a text string with HTML contents, which must be rendered instead of escaped.');
static::assertSame('<span class="text-danger">Tab</span> <b>7</b>', trim($crawler->filter('ul.nav-tabs #tablist-tab-tab-7')->html()), 'The "Tab 7" defines its label as a text string with HTML contents, which must be rendered instead of escaped.');
static::assertSame('#tab-tab-7', $crawler->filter('ul.nav-tabs #tablist-tab-tab-7')->attr('href'), 'Tabs with labels get IDs generated as the slugs of their labels but HTML tags must be removed.');
static::assertSame('<a href="https://example.com">Column</a> <b>7</b>', trim($crawler->filter('.form-column.column-7 .form-column-title-content')->html()), 'The "Column 7" defines its label as a text string with HTML contents, which must be rendered instead of escaped.');
static::assertSelectorNotExists('.form-column.column-7.form-column-no-header');
Expand All @@ -98,7 +98,7 @@ public function testFieldsLabelsInForms()
static::assertSame($crawler->filter('label[for="BlogPost_author"]')->html(), '<a href="https://example.com">Author</a> <b>Lorem</b> Ipsum', 'The "author" field defines its label as regular string with HTML contents, which must be rendered instead of escaped (HTML is allowed in field labels).');

// fields with a label defined as a translatable string with HTML contents
static::assertSame('<a href="https://example.com">Tab</a> <b>8</b>', trim($crawler->filter('ul.nav-tabs #tablist-tab-tab-8')->html()), 'The "Tab 8" defines its label as a translatable string with HTML contents, which must be rendered instead of escaped.');
static::assertSame('<span class="text-danger">Tab</span> <b>8</b>', trim($crawler->filter('ul.nav-tabs #tablist-tab-tab-8')->html()), 'The "Tab 8" defines its label as a translatable string with HTML contents, which must be rendered instead of escaped.');
static::assertSame('#tab-tab-8', $crawler->filter('ul.nav-tabs #tablist-tab-tab-8')->attr('href'), 'Tabs with labels get IDs generated as the slugs of their labels but HTML tags must be removed.');
static::assertSame('<a href="https://example.com">Column</a> <b>8</b>', trim($crawler->filter('.form-column.column-8 .form-column-title-content')->html()), 'The "Column 8" defines its label as a translatable string with HTML contents, which must be rendered instead of escaped.');
static::assertSelectorNotExists('.form-column.column-8.form-column-no-header');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ public function configureFields(string $pageName): iterable
DateTimeField::new('publishedAt', t('PublishedAt Lorem Ipsum'))->addCssClass('field-published-at'),

// fields with a label defined as a string with HTML contents
FormField::addTab('<a href="https://example.com">Tab</a> <b>7</b>'),
// don't use <a> tags in the tab label because tabs are rendered inside <a> tags and that causes issues
FormField::addTab('<span class="text-danger">Tab</span> <b>7</b>'),
FormField::addColumn(label: '<a href="https://example.com">Column</a> <b>7</b>')->addCssClass('column-7'),
FormField::addFieldset(label: '<a href="https://example.com">Fieldset</a> <b>7</b>')->addCssClass('fieldset-7'),
AssociationField::new('author', '<a href="https://example.com">Author</a> <b>Lorem</b> Ipsum')->addCssClass('field-author'),

// fields with a label defined as a translatable string with HTML contents
FormField::addTab(t('<a href="https://example.com">Tab</a> <b>8</b>')),
// don't use <a> tags in the tab label because tabs are rendered inside <a> tags and that causes issues
FormField::addTab(t('<span class="text-danger">Tab</span> <b>8</b>')),
FormField::addColumn(label: t('<a href="https://example.com">Column</a> <b>8</b>'))->addCssClass('column-8'),
FormField::addFieldset(label: t('<a href="https://example.com">Fieldset</a> <b>8</b>'))->addCssClass('fieldset-8'),
AssociationField::new('publisher', t('<a href="https://example.com">Publisher</a> <b>Lorem</b> Ipsum'))->addCssClass('field-publisher'),
Expand Down

0 comments on commit 468b8a8

Please sign in to comment.