castopod/app/Views/Components/Forms/RadioButton.php
Yassine Doghri a746a781b4 feat(themes): set generic css variables for colors to enable instance themes
- set new colors using the css variables for theming in tailwind.config.js
- replace admin and
public colors with new variable enabled colors
2021-12-29 12:06:10 +00:00

36 lines
808 B
PHP

<?php
declare(strict_types=1);
namespace App\Views\Components\Forms;
class RadioButton extends FormComponent
{
protected bool $isChecked = false;
public function setIsChecked(string $value): void
{
$this->isChecked = $value === 'true';
}
public function render(): string
{
$radioInput = form_radio(
[
'id' => $this->value,
'name' => $this->name,
'class' => 'form-radio-btn bg-elevated',
],
$this->value,
old($this->name) ? old($this->name) === $this->value : $this->isChecked,
);
return <<<HTML
<div>
{$radioInput}
<label for="{$this->value}">{$this->slot}</label>
</div>
HTML;
}
}