Skip to content

Commit

Permalink
Add RequiredInterface to File input element. (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Jan 14, 2024
1 parent a6ca0d4 commit a170719
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Input/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@

use PHPForge\Html\Attribute;
use PHPForge\Html\Helper\Utils;
use PHPForge\Html\Input\Contract\RequiredInterface;

/**
* The input element with a type attribute whose value is "file" represents a list of file items, each consisting of a
* file name, a file type, and a file body (the contents of the file).
*
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.file.html#input.file
*/
final class File extends Base\AbstractInput
final class File extends Base\AbstractInput implements RequiredInterface
{
use Attribute\Custom\HasUnchecked;
use Attribute\Input\CanBeMultiple;
use Attribute\Input\CanBeRequired;
use Attribute\Input\HasAccept;

protected function loadDefaultDefinitions(): array
Expand Down
12 changes: 11 additions & 1 deletion tests/Input/File/RenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ public function testReadonly(): void
);
}

public function testRequired(): void
{
Assert::equalsWithoutLE(
<<<HTML
<input id="file-65a15e0439570" type="file" required>
HTML,
File::widget()->id('file-65a15e0439570')->required()->render()
);
}

public function testStyle(): void
{
Assert::equalsWithoutLE(
Expand Down Expand Up @@ -335,7 +345,7 @@ public function testSuffixContainerTag(): void
);
}

public function tabIndex(): void
public function testTabIndex(): void
{
Assert::equalsWithoutLE(
<<<HTML
Expand Down

0 comments on commit a170719

Please sign in to comment.