FluidTYPO3\Vhs\ViewHelpers\Form\SelectViewHelper::getSelectedValue PHP Method

getSelectedValue() protected method

Retrieves the selected value(s)
protected getSelectedValue ( ) : mixed
return mixed value string or an array of strings
    protected function getSelectedValue()
    {
        $value = $this->getValue();
        if (!isset($this->arguments['optionValueField']) || empty($this->arguments['optionValueField'])) {
            return $value;
        }
        if (!is_array($value) && !$value instanceof \Iterator) {
            if (is_object($value)) {
                return ObjectAccess::getProperty($value, $this->arguments['optionValueField']);
            } else {
                return $value;
            }
        }
        $selectedValues = [];
        foreach ($value as $selectedValueElement) {
            if (is_object($selectedValueElement)) {
                $selectedValues[] = ObjectAccess::getProperty($selectedValueElement, $this->arguments['optionValueField']);
            } else {
                $selectedValues[] = $selectedValueElement;
            }
        }
        return $selectedValues;
    }