Contao\Widget::isValidOption PHP Method

isValidOption() protected method

Check whether an input is one of the given options
protected isValidOption ( mixed $varInput ) : boolean
$varInput mixed The input string or array
return boolean True if the selected option exists
    protected function isValidOption($varInput)
    {
        if (!is_array($varInput)) {
            $varInput = array($varInput);
        }
        // Check each option
        foreach ($varInput as $strInput) {
            $blnFound = false;
            foreach ($this->arrOptions as $v) {
                // Single dimensional array
                if (array_key_exists('value', $v)) {
                    if ($strInput == $v['value']) {
                        $blnFound = true;
                    }
                } else {
                    foreach ($v as $vv) {
                        if ($strInput == $vv['value']) {
                            $blnFound = true;
                        }
                    }
                }
            }
            if (!$blnFound) {
                return false;
            }
        }
        return true;
    }