Option value setter
@param string|bool $value option value
@return Option self
772197
public function setValue($value) {
        switch ($this->type) {
            case self::TYPE_BOOLEAN:
                $this->value = (bool) $value;
                break;
            case self::TYPE_STRING:
                $this->value = (string) $value;
                break;
        }
        return $this;
    }
906164
public function setValue($value)
    {
        if (!isset($value)) {
            unset($this->value);
            return $this;
        }
        $this->value = (string) $value;
        return $this;
    }
1329462
public function setValue($value) {
        global $DB;
        $values = (array) $value;
        $ids = array();

        foreach ($values as $onevalue) {
            if (!empty($onevalue) && (!$this->optionExists($onevalue)) &&
                    ($onevalue !== '_qf__force_multiselect_submission')) {
                array_push($ids, $onevalue);
            }
        }

        if (empty($ids)) {
            return $this->setSelected(array());
        }

        // Logic here is simulating API.
        $toselect = array();
        list($insql, $inparams) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED, 'param');
        $frameworks = competency_framework::get_records_select("id $insql", $inparams, 'shortname');
        foreach ($frameworks as $framework) {
            if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'),
                    $framework->get_context())) {
                continue;
            } else if ($this->onlyvisible && !$framework->get('visible')) {
                continue;
            }
            $this->addOption($framework->get('shortname') . ' ' . $framework->get('idnumber'), $framework->get('id'));
            array_push($toselect, $framework->get('id'));
        }

        return $this->setSelected($toselect);
    }
941848
public function setChecked($value=true){
		if($value===true){
			$this->getDataField()->setProperty("checked", "checked");
		}else{
			$this->getDataField()->removeProperty("checked");
		}
		return $this;
	}
419482
public function setValue($value)
	{
		if ( is_array($value) ) {
			return $this->setSelected($value);
		}

		return $this->selectByValue((string)$value);
	}
198825
private function parseOptionValue($value = null)
    {
        if (\is_bool($value)) {
            $value = $value === true ? 'true' : 'false';
        } elseif (\is_null($value)) {
            $value = 'null';
        } elseif (\is_string($value)) {
            $value = '\''.$value.'\'';
        }
        return $value;
    }
177665
public function setDefaultValue($value): Property
    {
        $this->hasDefault = true;
        $this->defaultValue = $value;

        return $this;
    }
41420
public function setOption($option, $value = null)
    {
        if (is_array($option)) {
            $this->options += $option;
        } else {
            $this->options[$option] = $value;
        }

        return $this;
    }
1144971
public function setValue($value)
    {
        $this->hash = sha1("$value");
        $this->value = $value;
        $this->valueSet = true;
        return $this;
    }
538448
public function modifyValue($value) : self
    {
        $this->attributes['value'] = $this->getOldValue() ?: $value;

        if ($value instanceof \Closure) {
            $this->attributes['value'] = $value($this->attributes);
        }

        return $this;
    }
930819
public function setFieldOption(string $option, $value): self
    {
        //Retrieve the single existing field for alteration.
        $params = $this->getParams();
        if (\count($params) < 1) {
            throw new InvalidException('No field has been set');
        }
        $key = \key($params);
        $params[$key][$option] = $value;

        return $this->setParam($key, $params[$key]);
    }
203915
public function setUserValue(string $value) : self
    {
        $this->user_value = $value;
        $this->is_valid = null;
        return $this;
    }
220701
public function setOption($option, $value)
    {
        if (null !== $this->logger) {
            $this->logger->startMethod('setOption', ['option' => $option, 'value' => $value]);
        }

        if (!$this->setOptionImpl($option, $value)) {
            $this->stopMethod();

            return false;
        }

        $this->setResultOK();
        $this->stopMethod();

        return true;
    }
703214
public function setValue($value)
    {
        if (null === $value) {
            $value = $this->getArgument('default');
        }

        $this->value = ($this->needsSanitization())
            ? $this->sanitizeWithCallback($value)
            : $value;

        return $this;
    }
376823
public function withNoScript(bool $value = true) : self
    {
        $that = clone($this);
        $that->noScript = $value;
        return $that;
    }
607544
protected function booleanValue($value)
    {
        if (is_bool($value)) {
            return $value;
        }

        if (is_numeric($value)) {
            return (Boolean) $value;
        }

        return in_array(strtolower($value),  [ 'true', 't', 'y', 'yes' ], true);
    }
1295237
public function setValue(string $value) : SingleSelect
    {
        $oneSelected = false;

        foreach ($this->getOptions() as $option) {
            $thisSelected = ! $oneSelected && $option->getValue() === $value;
            $oneSelected = $oneSelected || $thisSelected;
            $option->setSelected($thisSelected);
        }

        return $this;
    }