<?php

namespace Plainwork\Ui\Component\Form;

use Plainwork\Http\Request;
use Plainwork\Ui\Component\Form\AbstractInput;

class RadioInput extends AbstractInput
{
    private bool $on = false;
    // private bool $value = false;
    // private string $htmlValue = '1';
    private string $value = '1';
    private $label = null;

    public function grab(Request $request): ?string
    {
        $ret = $request->getPostParam($this->getName());

        return $ret;
    }

    public function setOn(bool $v): self
    {
        $this->on = $v;

        return $this;
    }

    public function isOn(): bool
    {
        return $this->on ? true : false;
    }

    public function setValue(string $v): self
    {
        $this->value = $v;

        return $this;
    }

    public function getValue(): string
    {
        return $this->value;
    }

    public function setLabel($v): self
    {
        $this->label = $v;

        return $this;
    }

    public function getLabel()
    {
        return $this->label;
    }
}
