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 new classes and tests for input elements. (#169)
- Loading branch information
1 parent
77cfd82
commit 3c97f05
Showing
16 changed files
with
313 additions
and
327 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
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
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
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
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
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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Input\Base; | ||
|
||
use InvalidArgumentException; | ||
use PHPForge\Html\Attribute; | ||
use PHPForge\Html\Input\PlaceholderInterface; | ||
use PHPForge\Html\Input\RuleHtmlByAttributeInterface; | ||
|
||
use function is_string; | ||
use function sprintf; | ||
|
||
abstract class AbstractText extends AbstractInput implements PlaceholderInterface, RuleHtmlByAttributeInterface | ||
{ | ||
use Attribute\Input\CanBeRequired; | ||
use Attribute\Input\HasDirname; | ||
use Attribute\Input\HasMaxLength; | ||
use Attribute\Input\HasMinLength; | ||
use Attribute\Input\HasPattern; | ||
use Attribute\Input\HasPlaceholder; | ||
use Attribute\Input\HasSize; | ||
|
||
protected function run(): string | ||
{ | ||
$attributes = $this->attributes; | ||
$value = $attributes['value'] ?? null; | ||
|
||
/** | ||
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.text.html#input.text.attrs.value | ||
*/ | ||
if ($value !== null && is_string($value) === false) { | ||
throw new InvalidArgumentException( | ||
sprintf('%s::class widget must be a string or null value.', static::class) | ||
); | ||
} | ||
|
||
return $this->buildInputTag($attributes, 'text')->render(); | ||
} | ||
} |
Oops, something went wrong.