dokuwiki\Form\DropdownElement::val PHP Метод

val() публичный Метод

When setting a value that is not defined in the options, the value is ignored and the first option's value is selected instead
public val ( null | string $value = null )
$value null | string The value to set
    public function val($value = null)
    {
        if ($value === null) {
            return $this->value;
        }
        $value_exists = $this->setValueInOptGroups($value);
        if ($value_exists) {
            $this->value = $value;
        } else {
            // unknown value set, select first option instead
            $this->value = $this->getFirstOption();
            $this->setValueInOptGroups($this->value);
        }
        return $this;
    }