<?php

namespace Plainwork\Ui\Component\Form;

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

class SelectInput extends AbstractInput
{
    private ?string $value = '';
    private array $options = [];

    public function setOptions(array $options): self
    {
        $this->options = $options;

        return $this;
    }

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

        return $ret;
    }

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

        return $this;
    }

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

    public function getOptions(): array
    {
        return $this->options;
    }
}
