Skip to content

Commit

Permalink
allow disabled- and form-Attribute on fieldsets
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Müller <mimmi20@live.de>
  • Loading branch information
mimmi20 committed Jan 3, 2024
1 parent 6f6c60a commit c73f83c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/View/Helper/FormCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class FormCollection extends AbstractHelper
* @var array
*/
protected $validTagAttributes = [
'name' => true,
'name' => true,
'disabled' => true,
'form' => true,
];

/**
Expand Down
42 changes: 42 additions & 0 deletions test/View/Helper/FormCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,4 +462,46 @@ public static function provideDoctypesAndPermitFlagForNameAttribute(): array
[Doctype::CUSTOM, false],
];
}

/**
* @dataProvider provideDoctypesAndPermitFlagForDisabledAttribute
*/
public function testRenderCollectionWithDisabledAttribute(
string $doctype,
bool $allowsShortAttribute
): void {
$this->helper->setDoctype($doctype);

$form = $this->getForm();
$collection = $form->get('colors');
$collection->setAttribute('disabled', true);

$markup = $this->helper->render($collection);

if ($allowsShortAttribute) {
self::assertStringContainsString('<fieldset name="colors" disabled>', $markup);
} elseif ($doctype === Doctype::XHTML5) {
self::assertStringContainsString('<fieldset name="colors" disabled="disabled">', $markup);
} else {
self::assertStringContainsString('<fieldset disabled="disabled">', $markup);
}
}

public static function provideDoctypesAndPermitFlagForDisabledAttribute(): array
{
return [
[Doctype::XHTML11, false],
[Doctype::XHTML1_STRICT, false],
[Doctype::XHTML1_TRANSITIONAL, false],
[Doctype::XHTML1_FRAMESET, false],
[Doctype::XHTML1_RDFA, false],
[Doctype::XHTML1_RDFA11, false],
[Doctype::XHTML_BASIC1, false],
[Doctype::XHTML5, false],
[Doctype::HTML4_STRICT, false],
[Doctype::HTML4_LOOSE, false],
[Doctype::HTML4_FRAMESET, false],
[Doctype::HTML5, true],
];
}
}

0 comments on commit c73f83c

Please sign in to comment.