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.
- Loading branch information
1 parent
a170719
commit d3fb834
Showing
7 changed files
with
540 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Input; | ||
|
||
use PHPForge\Html\Attribute; | ||
|
||
/** | ||
* The input element with a type attribute whose value is "image" represents either an image from which the UA enables a | ||
* user to interactively select a pair of coordinates and submit the form, or alternatively a button from which the user | ||
* can submit the form. | ||
* | ||
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.image.html#input.image | ||
*/ | ||
final class Image extends Base\AbstractInput | ||
{ | ||
use Attribute\Custom\HasWidgetValidation; | ||
use Attribute\Input\HasAlt; | ||
use Attribute\Input\HasFormaction; | ||
use Attribute\Input\HasFormenctype; | ||
use Attribute\Input\HasFormmethod; | ||
use Attribute\Input\HasFormnovalidate; | ||
use Attribute\Input\HasFormtarget; | ||
use Attribute\Input\HasHeight; | ||
use Attribute\Input\HasSrc; | ||
use Attribute\Input\HasWidth; | ||
|
||
protected function run(): string | ||
{ | ||
$attributes = $this->attributes; | ||
$value = $attributes['src'] ?? $this->getValue(); | ||
$this->validateString($value); | ||
|
||
unset($attributes['value']); | ||
|
||
$attributes['src'] = $value; | ||
|
||
return $this->buildInputTag($attributes, 'image'); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Tests\Input\Image; | ||
|
||
use InvalidArgumentException; | ||
use PHPForge\Html\Input\Image; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @psalm-suppress PropertyNotSetInConstructor | ||
*/ | ||
final class ExceptionTest extends TestCase | ||
{ | ||
public function testValue(): void | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Image::class widget must be a string or null value.'); | ||
|
||
Image::widget()->value(1)->render(); | ||
} | ||
} |
Oops, something went wrong.