Set the available choices for a select field as an array of key value pairs

@param Option $choices
@return Agencms\Core\Field
970563
public function addOption(Option ...$choices)
    {
        collect($choices)->map(function ($choice) {
            $this->field['choices']->push($choice->get());
        });

        return $this;
    }
482336
public function setOptions(array $options)
    {
        foreach ($options as $option => $value) {
            if (property_exists($this, $option)) {
                $this->{$option} = $value;
            }
        }

        return $this;
    }
1228143
public function setOptions( $options ) {
		$this->options = [];

		$this->datalist->clearContent();
		foreach ( $options as $opt ) {
			$option = ( new Tag( 'option' ) )
				->setAttributes( [ 'value' => $opt['data'] ] )
				->appendContent( $opt['label'] ?? $opt['data'] );

			$this->options[] = $option;
			$this->datalist->appendContent( $option );
		}

		return $this;
	}
214881
public function set_options(array $options)
	{
		foreach ($options as $key => $val)
		{
			$this->options[$key] = $val;
		}

		return $this;
	}
960001
public function setOptions(array $options): FieldTypeInterface
    {
        $this->validateOptions($options);
        $this->options = $this->parseOptions(array_merge(
            $this->getDefaultOptions(),
            $this->options,
            $options
        ));

        return $this;
    }
19600
protected function parse(array $choices)
    {
        $items = [];

        foreach ($choices as $key => $value) {
            if (is_array($value)) {
                $items[$key] = $this->parse($value);
            } else {
                if (is_int($key)) {
                    $label = ucfirst(str_replace(['-', '_'], ' ', $value));
                } else {
                    $label = $key;
                }

                $items[$label] = $value;
            }
        }

        return $items;
    }
1308664
private function setSelect2Options ($select2options)
    {
        foreach ($select2options as $key => $option)
            $this->select2options[$key] = $option;
        return $this;
    }
212582
protected function setOptionalValueInArray(string $name, &$values)
    {
        if ($this->isOptional($name) && !array_key_exists($name, $values)) {
            $default = $this->getFieldProperty($name, 'default');

            if (is_null($default)) {
                $type = $this->getFieldProperty($name, 'type');

                switch ($type) {
                    case 'list':
                        $default = array();
                        break;
                    case 'bool':
                        $default = false;
                        break;
                }
            }

            $values[$name] = $default;
        }

        return $this;
    }
1201749
public function setOptions(array $options): FieldTypeInterface
    {
        $l10n = $this->handleLocalization($options);

        $options = array_merge(
            $this->getDefaultOptions(),
            $this->options,
            $options
        );

        if (isset($options['l10n']) && ! empty($l10n)) {
            $options['l10n'] = array_merge($options['l10n'], $l10n);
        }

        $this->options = $this->parseOptions($options);

        return $this;
    }
326315
public function options($options = [])
    {
        if ($options instanceof Arrayable) {
            $options = $options->toArray();
        }

        $this->options = array_merge($this->options, $options);

        return $this;
    }
294275
public function addChoices(array $choices)
    {
        foreach ($choices as $k => $v) {
            if (is_int($k)) {
                $k = $this->sensible($v);
            }
            $this->choices[$k] = $v;
        }

        return $this;
    }
1191580
public function setOptions(array $options)
    {
        if (count($options)) {
            foreach ($options as $method => $value) {
                $method = camelcase('set_' . $method);

                if (method_exists($this, $method)) {
                    call_user_func_array([&$this, $method], [$value]);
                }
            }
        }

        return $this;
    }
1092970
public function setChoices($choices)
    {
        $this->reset();

        $flatten = $this->flatten($choices);
        if ($this->config['sort']) {
            ksort($flatten);
        }

        /*
         * $path = Db.Lang.php
         * $name = PHP
         */
        foreach ($flatten as $path => $name) {
            $ns = substr($path, 0, strrpos($path, '.'));
            $this->choices[$ns] = $ns;
            if (isset($flatten["{$ns}._"])) {
                $this->groups[$ns] = $flatten["{$ns}._"] + ['max' => PHP_INT_MAX];
                unset($flatten["{$ns}._"]);
            }

            $key = substr($path, strrpos($path, '.') + 1); // php
            if ($key == '_') {
                continue;
            }

            $isSelected = in_array($key, (array)($this->groups[$ns]['selected'] ?? []));
            $this->choices[] = [
                'key'      => $key,
                'ns'       => $ns,
                'name'     => $name,
                'selected' => $isSelected,
                'readonly' => in_array($key, $this->groups[$ns]['readonly'] ?? []),
                'depends'  => (array)($this->groups[$ns]['depends'][$key] ?? []),
            ];

            if ($isSelected) {
                $this->selections[$key] = $ns;
            }

            if (!isset($this->groups[$ns])) {
                $this->groups[$ns] = ['max' => PHP_INT_MAX];
            }
        }

        $this->choices = array_values($this->choices);
        $this->lines   = count($this->choices);
        $this->line    = $this->lines - 1;
    }
1195659
public function setOptions($options = [])
    {
        $this->options = $options;
        $this->debug->info(__FUNCTION__, 'setOptions: ', $this->options);

        return $this;
    }
1356180
public function addOptions(array $options) : Select
    {
        foreach ($options as $value => $content) {
            $this->addOption($content, $value);
        }

        return $this;
    }
294520
public function addOptions(array $options)
    {
        foreach ($options as $name => $value) {
            $this->addOption($name, $value);
        }

        return $this;
    }
732930
public function setSelected(array $values)
	{
		$this->assertMultiSelect();

		$candidates = array();
		/* @var $candidates SelectOption[] */

		foreach ( $this->getOptions() as $option ) {
			if ( in_array($option->getValue(), $values) ) {
				$candidates[] = $option;
			}
		}

		return $this->selectOptions($candidates);
	}