mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-23 01:01:20 +00:00
35 lines
784 B
PHP
35 lines
784 B
PHP
![]() |
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace Modules\Plugins\Manifest\Fields;
|
||
|
|
||
|
use Modules\Plugins\Manifest\Field;
|
||
|
|
||
|
/**
|
||
|
* @property bool $defaultValue
|
||
|
*/
|
||
|
class Checkbox extends Field
|
||
|
{
|
||
|
public static array $validation_rules = [
|
||
|
'defaultValue' => 'permit_empty|is_boolean',
|
||
|
];
|
||
|
|
||
|
protected bool $defaultValue = false;
|
||
|
|
||
|
public function render(string $name, mixed $value, string $class = ''): string
|
||
|
{
|
||
|
$value = $value ? 'yes' : '';
|
||
|
return <<<HTML
|
||
|
<x-Forms.Checkbox
|
||
|
class="{$class}"
|
||
|
name="{$name}"
|
||
|
hint="{$this->hint}"
|
||
|
helper="{$this->helper}"
|
||
|
value="{$value}"
|
||
|
defaultValue="{$this->defaultValue}"
|
||
|
>{$this->label}</x-Forms.Checkbox>
|
||
|
HTML;
|
||
|
}
|
||
|
}
|