mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-22 16:51:20 +00:00
39 lines
886 B
PHP
39 lines
886 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\Plugins\Manifest\Fields;
|
|
|
|
use Modules\Plugins\Manifest\Field;
|
|
|
|
/**
|
|
* @property int|null $defaultValue
|
|
*/
|
|
class Number extends Field
|
|
{
|
|
public static array $validation_rules = [
|
|
'defaultValue' => 'permit_empty|numeric',
|
|
];
|
|
|
|
protected ?int $defaultValue = null;
|
|
|
|
public function render(string $name, mixed $value, string $class = ''): string
|
|
{
|
|
$isRequired = $this->optional ? 'false' : 'true';
|
|
return <<<HTML
|
|
<x-Forms.Field
|
|
as="Input"
|
|
type="number"
|
|
class="{$class}"
|
|
name="{$name}"
|
|
label="{$this->label}"
|
|
hint="{$this->hint}"
|
|
helper="{$this->helper}"
|
|
isRequired="{$isRequired}"
|
|
value="{$value}"
|
|
defaultValue="{$this->defaultValue}"
|
|
/>
|
|
HTML;
|
|
}
|
|
}
|