for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Yiisoft\Form\Field;
use Stringable;
use Yiisoft\Form\Field\Base\AbstractSimpleField;
use Yiisoft\Html\Html;
/**
* @link https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image)
*/
final class Image extends AbstractSimpleField
{
private array $inputTagAttributes = [];
* Provides the textual label for the button for users and user agents who cannot use the image.
*
* @link https://html.spec.whatwg.org/multipage/input.html#attr-input-alt
public function alt(?string $value): self
$new = clone $this;
$new->inputTagAttributes['alt'] = $value;
return $new;
}
public function width(int|string|Stringable|null $width): self
$new->inputTagAttributes['width'] = $width;
public function height(int|string|Stringable|null $height): self
$new->inputTagAttributes['height'] = $height;
* @link https://html.spec.whatwg.org/multipage/input.html#attr-input-src
public function src(?string $url): self
$new->inputTagAttributes['src'] = $url;
public function disabled(?bool $disabled = true): self
$new->inputTagAttributes['disabled'] = $disabled;
public function inputTagAttributes(array $attributes): self
$new->inputTagAttributes = $attributes;
protected function generateInput(): string
return Html::input(
type: 'image',
attributes: $this->inputTagAttributes
)->render();