protected function get_selected_options($returntexts = true) {

        $method = 'getHtml';
        if ($returntexts === false) {
            $method = 'getValue';
        }

        // Is the select multiple?
        $multiple = $this->field->hasAttribute('multiple');

        $selectedoptions = array(); // To accumulate found selected options.

        // Driver returns the values as an array or as a string depending
        // on whether multiple options are selected or not.
        $values = $this->field->getValue();
        if (!is_array($values)) {
            $values = array($values);
        }

        // Get all the options in the select and extract their value/text pairs.
        $alloptions = $this->field->findAll('xpath', '//option');
        foreach ($alloptions as $option) {
            // Is it selected?
            if (in_array($option->getValue(), $values)) {
                if ($multiple) {
                    // If the select is multiple, text commas must be encoded.
                    $selectedoptions[] = trim(str_replace(',', '\,', $option->{$method}()));
                } else {
                    $selectedoptions[] = trim($option->{$method}());
                }
            }
        }

        return implode(', ', $selectedoptions);
    }