Create a select element option.

@param string $display
@param string $value
@param string $selected

@return string
979307
protected function option($display, $value, $selected)
    {
        $selected = $this->getSelectedValue($value, $selected);

        $options = array('value' => $this->html->entities($value), 'selected' => $selected);

        return '<option'.$this->html->attributes($options).'>'.$this->html->entities($display).'</option>';
    }
194851
public function options(array $options, string $selected=null) : self {
        foreach ($options as $key => $value) {
            if (is_int($key))
                $key = $value;
            if ($selected == $key)
                $this->elem("option @value=? @selected=selected", [$key])->text($value)->end();
            else
                $this->elem("option @value=?", [$key])->text($value)->end();
        }
        return $this;
    }
410421
public function lselectLocalizedOptionWithJavascript($selector, $option) {
        $localizedOption = $this->localizeTarget($option);
        $this->selectOptionWithJavascript($selector, $localizedOption);
    }
771344
private function selectComponentValue(DocumentElement $page, $component, $field, $value)
    {
        $select = $page->find('css', sprintf('#%s', $field));
        if (!$select) {
            throw new \Exception(sprintf('No select "%s" found', $field));
        }

        $selector = sprintf('.fs-%1$s button.fs-%1$s-item', $component);
        $choices  = $page->findAll('css', $selector);
        foreach ($choices as $choice) {
            if ($choice->getText() == $value) {
                $choice->click();
                return;
            }
        }

        throw new \Exception(sprintf('Value "%s" not found for "%s"', $value, $field));
    }
901226
protected function renderAPMOptionsSelected(string $key, string $value, string $selected): string
    {
        return ($key === $selected)
            ? sprintf('<option value="%s" selected="selected">%s</option>%s', $key, htmlentities($value, ENT_HTML5, 'UTF-8'), "\n")
            : sprintf('<option value="%s">%s</option>%s', $key, htmlentities($value, ENT_HTML5, 'UTF-8'), "\n");
    }
717398
public function generateSelectElement(array $options = array(), array $attributes = array(), $selectedValue = "", $templateToBeRendered = 'html_element_template')
    {
        $_options_html = "";

        foreach($options as $_option => $_val)
        {
            $_attributes = array("value" => $_val);

            if($_val == $selectedValue) {
                $_attributes['selected'] = "true";
            }

            $_options_html .= $this->generateElement(
                'option',
                $_attributes,
                $_val
            );
        }

        return $this->generateElement('select', $attributes, $_options_html, true, $templateToBeRendered);
    }
791265
public function waitUntilStatus($by, $value, $displayed = true, $timeout = 0)
    {
        try {
            /** @var \PHPUnit_Extensions_Selenium2TestCase_Element $element */
            return $this->waitUntil(function() use ($by, $value, $displayed) {
                /** @var \PHPUnit_Extensions_Selenium2TestCase_Element $element */
                $element = $this->$by($value);

                if ($displayed) {
                    return $element->displayed() && $element->enabled() ? $element : null;
                }

                return !$element->displayed() ? $element : null;
            }, empty($timeout) ? self::TIMEOUT_ELEMENT : $timeout);
        } catch (\Exception $exception) {
            $this->fail(
                $exception->getMessage() . ' | ' .
                __FUNCTION__ . ' | ' . $by . ' | ' . $value . ' | ' . ($displayed ? 'displayed' : 'hidden')
            );

            return $this->$by($value);
        }
    }
170183
public function makeSelected($config, $selected, $custom)
    {
        $options = $prefix = $suffix = '';

        if (isset($config['config']['multiple'])) {
            $custom = 'multiple';
            $config['name'] = $config['name'].'[]';
        }

        if (config('form-maker.form.orientation') === 'horizontal') {
            $prefix = '<div class="'.config('form-maker.form.input-column').'">';
            $suffix = '</div>';
        }

        foreach ($config['config']['options'] as $key => $value) {
            $selectedValue = '';

            if (isset($config['config']['multiple']) && is_object($selected)) {
                if (in_array($value, $selected->toArray())) {
                    $selectedValue = 'selected';
                }
            } else {
                if ($selected == '') {
                    $selectedValue = ((string) $config['objectValue'] === (string) $value) ? 'selected' : '';
                } else {
                    if (isset($config['objectValue']) && is_array(json_decode($config['objectValue']))) {
                        $selectedValue = (in_array($value, json_decode($config['objectValue']))) ? 'selected' : '';
                    } else {
                        $selectedValue = ((string) $selected === (string) $value) ? 'selected' : '';
                    }
                }
            }

            $options .= '<option value="'.$value.'" '.$selectedValue.'>'.$key.'</option>';
        }

        return $prefix.'<select '.$this->processCustom($custom).' id="'.$this->getId($config).'" class="'.$config['class'].'" name="'.$config['name'].'">'.$options.'</select>'.$suffix;
    }
785621
protected static function LT(DBInterfaces\IDatabaseConnection $connection, Selectable $field, Selectable $value)
    {
        $op = '<';
        return self::CreateElementary($connection, $field, $value, $op);
    }
772221
private static function getOptions(array $values, array $selected, int $level = 0): array
    {
        $options = [];
        foreach ($values as $k => $v) {
            if (\strpos((string)$k, 'OPTGROUP') !== false) {
                $label = \str_replace(['&amp;nbsp;', '&amp;'], [Tags::NBSP, '&'], \htmlspecialchars((string)$v['name']));
                $optAttributes = ['label' => $label];
                if ($level > 0) {
                    $optAttributes['style'] = 'padding-left: '.(10 * $level).'px';
                }
                $options[] = Tags::optgroup(self::getOptions($v['options'], $selected, $level + 1), $optAttributes);
            } else {
                $optAttributes = [
                    'value' => $k,
                    'class' => 'opt-'.\str_replace('/', '', $k),
                ];
                if ($level > 0) {
                    $optAttributes['style'] = 'padding-left: '.(10 * $level).'px';
                }
                if (\in_array($k, $selected)) {
                    $optAttributes['selected'] = 'selected';
                }
                $options[] = Tags::option(
                    \str_replace(['&amp;nbsp;', '&amp;'], [Tags::NBSP, '&'], \htmlspecialchars((string)$v)),
                    $optAttributes
                );
            }
        }
        return $options;
    }
981239
@When("^I select '(.+?)' on the element on index '(\\d+?)'$")
    public void elementSelect(String option, Integer index) {
        Select sel = null;
        sel = new Select(commonspec.getPreviousWebElements().getPreviousWebElements().get(index));

        sel.selectByVisibleText(option);
    }
78357
public function selected($field, $value)
    {
        $options = $this->resolver->resolveSelectOptions($field, (array) $value);

        return collect($options)->contains(function (RemoteWebElement $option) {
            return $option->isSelected();
        });
    }
1039346
private function _generate(&$options, &$selected, $level = 0)
    {

        $content = '';

        // character(s) used for indenting levels
        $indent = '&nbsp;&nbsp;';

        // iterate through the available options
        foreach ($options as $value => $caption) {

            // if option has child options
            if (is_array($caption)) {

                // create a dummy option group (for valid HTML/XHTML we are not allowed to create nested option groups
                // and also empty optiongroups are not allowed)
                // BUT because in IE7 the "disabled" attribute is not supported and in all versions of IE these
                // can't be styled, we will remove them from JavaScript
                // having a dummy option in them (the option is disabled and, from CSS, rendered invisible)
                $content .= '
                    <optgroup label="' . str_repeat($indent, $level) . $value . '">
                        <option disabled="disabled" class="dummy"></option>
                    </optgroup>
                ';

                // call the method recursively to generate the output for the children options
                $content .= $this->_generate($caption, $selected, $level + 1);

            // if entry is a standard option
            } else {

                // create the appropriate code
                $content .= '<option value="' . $value . '"' .

                    // if anything was selected
					($selected !== '' && $value !== '' &&

                    	(

                            // and the current option is selected
    						(is_array($selected) && in_array($value, $selected)) ||

                    		(!is_array($selected) && (string)$value === (string)$selected)

                        // set the appropriate attribute
    					) ? ' selected="selected"' : ''

                    ) . '>' .

                // indent appropriately
                str_repeat($indent, $level) . $caption . '</option>';

            }

        }

        // return generated content
        return $content;

    }
286704
public static function selectOption($option, $value)
    {
        $attributes = [''];

        $attributes[] = "value=\"{$option['value']}\"";

        if (
            (is_array($value) && in_array($option['value'], $value))
            || ($option['value'] == $value)
        ) {
            $attributes[] = 'selected="selected"';
        }

        $attributes = implode(' ', $attributes);
        return "<option {$attributes}>{$option['label']}</option>";
    }
1024617
static function select($name, $option, $default = null, $self = null, $attrArray = null, $add_help = true, $force = false)
	{
		$htmlStr = "<select name=\"$name\" id=\"$name\"";
		$htmlStr .= self::input_attr($attrArray) . ">\n";

        if ($add_help) {
            if ($add_help === true) {
                $htmlStr .= "<option value=\"\">" . self::$default_help_option . "</option>\n";
            } else {
                $htmlStr .= "<option value=\"\">$add_help</option>\n";
            }
        }
        foreach ($option as $key => $value) {
            if ($self) {
                $key = $value;
            }

            if (!$force and $key == $default) {
                $htmlStr .= "<option value=\"{$key}\" selected=\"selected\">{$value}</option>\n";
            } elseif ($force and $key === $default) {
				$htmlStr .= "<option value=\"{$key}\" selected=\"selected\">{$value}</option>\n";
			} else {
                $htmlStr .= "<option value=\"{$key}\">{$value}</option>\n";
            }
        }
        $htmlStr .= "</select>\n";

		return $htmlStr;
	}
193980
public function clickDisplayedElementByClass($value, $timeout = 0)
    {
        return $this->clickDisplayedElement(self::BY_CLASS_NAME, $value, $timeout, $timeout);
    }
1003009
protected function select($value, $element)
    {
        $this->wd->findElement(WebDriverBy::cssSelector($element))->sendKeys($value);

        return $this;
    }