generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add input
Email::class
widget. (#234)
- Loading branch information
1 parent
fe7f47e
commit fe9ec4c
Showing
3 changed files
with
497 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Input; | ||
|
||
use PHPForge\Html\Attribute; | ||
|
||
/** | ||
* The input element with a type attribute whose value is "email" represents a control for editing a list of e-mail | ||
* addresses given in the element’s value. | ||
* | ||
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.email.html#input.email | ||
*/ | ||
final class Email extends Base\AbstractInput implements | ||
Contract\LengthInterface, | ||
Contract\PatternInterface, | ||
Contract\PlaceholderInterface, | ||
Contract\RequiredInterface | ||
{ | ||
use Attribute\Custom\HasWidgetValidation; | ||
use Attribute\Input\CanBeMultiple; | ||
use Attribute\Input\CanBeRequired; | ||
use Attribute\Input\HasMaxLength; | ||
use Attribute\Input\HasMinLength; | ||
use Attribute\Input\HasPattern; | ||
use Attribute\Input\HasPlaceholder; | ||
use Attribute\Input\HasSize; | ||
|
||
protected function run(): string | ||
{ | ||
$this->validateString($this->getValue()); | ||
|
||
return $this->buildInputTag($this->attributes, 'email'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Tests\Input\Email; | ||
|
||
use InvalidArgumentException; | ||
use PHPForge\Html\Input\Email; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @psalm-suppress PropertyNotSetInConstructor | ||
*/ | ||
final class ExceptionTest extends TestCase | ||
{ | ||
public function testValue(): void | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Email::class widget must be a string or null value.'); | ||
|
||
Email::widget()->value(1)->render(); | ||
} | ||
} |
Oops, something went wrong.