Skip to content

Commit

Permalink
Add placeholder attribute to AbstractHidden and AbstractInput classes. (
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Dec 21, 2023
1 parent a5643ca commit 9100984
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Input/Base/AbstractHidden.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ abstract class AbstractHidden extends AbstractInput
'autofocus',
'disabled',
'hidden',
'placeholder',
'required',
'readonly',
'tabindex',
Expand Down
1 change: 1 addition & 0 deletions src/Input/Base/AbstractInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ abstract class AbstractInput extends Element implements InputInterface
use Attribute\Input\CanBeRequired;
use Attribute\Input\HasForm;
use Attribute\Input\HasName;
use Attribute\Input\HasPlaceholder;
use Attribute\Input\HasType;
use Attribute\Input\HasValue;

Expand Down
8 changes: 8 additions & 0 deletions tests/Input/Hidden/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public function testHidden(): void
Hidden::widget()->hidden()->render();
}

public function testPlaceholder(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Hidden::class widget must not be "placeholder" attribute.');

Hidden::widget()->placeholder('test-placeholder')->render();
}

public function testRequired(): void
{
$this->expectException(InvalidArgumentException::class);
Expand Down
10 changes: 10 additions & 0 deletions tests/Input/RenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ public function testName(): void
);
}

public function testPlaceholder(): void
{
Assert::equalsWithoutLE(
<<<HTML
<input id="text-6582f2d099e8b" type="text" placeholder="placeholder">
HTML,
Input::widget()->id('text-6582f2d099e8b')->placeholder('placeholder')->render()
);
}

public function testPrefix(): void
{
Assert::equalsWithoutLE(
Expand Down

0 comments on commit 9100984

Please sign in to comment.