55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
namespace nur\v\bs3\fo;
|
|
|
|
use nur\b\params\Tparametrable;
|
|
use nur\v\v;
|
|
|
|
class ControlRadiobutton extends ControlVisual {
|
|
use Tparametrable;
|
|
|
|
const PARAMETRABLE_PARAMS_SCHEMA = [
|
|
"text" => ["?content", null, "libellé du bouton radio"],
|
|
"checked" => ["?bool", null, "le bouton est-il sélectionné?"],
|
|
"naked_label" => ["?bool", null, "faut-il retourner le bouton avec le label en mode naked?"]
|
|
];
|
|
|
|
/** @var array|string */
|
|
protected $ppText;
|
|
|
|
/** @var bool */
|
|
protected $ppChecked;
|
|
|
|
/** @var bool */
|
|
protected $ppNakedLabel;
|
|
|
|
function getControl(): array {
|
|
$name = $this->ppName;
|
|
$value = $this->ppValue;
|
|
$checked = $this->ppChecked;
|
|
$disabled = $this->ppDisabled;
|
|
$control = v::tag1("input", [
|
|
"type" => "radio",
|
|
"id" => $this->ppId,
|
|
"name" => $name,
|
|
"value" => $value,
|
|
"checked" => $checked? "checked": false,
|
|
"readonly" => $this->ppReadonly? "readonly": false,
|
|
"disabled" => $disabled ? "disabled": false,
|
|
"class" => $this->ppClass,
|
|
"style" => $this->ppStyle,
|
|
$this->ppAttrs,
|
|
]);
|
|
if ($this->ppNaked && !$this->ppNakedLabel) return $control;
|
|
|
|
$controlLabel = v::div([
|
|
"class" => ["radio", $disabled ? "disabled" : false],
|
|
v::tag("label", [
|
|
$control, " ", q($this->ppText),
|
|
]),
|
|
]);
|
|
if ($this->ppNaked) return $controlLabel;
|
|
|
|
return $this->getFgsLayout($controlLabel);
|
|
}
|
|
}
|