Load a value into this MultiSelectField

@param mixed $value
@param null|array|DataObject $obj {@see Form::loadDataFrom}
@return $this
492950
public function setValue($value, $obj = null)
    {
        // If we're not passed a value directly,
        // we can look for it in a relation method on the object passed as a second arg
        if ($obj instanceof DataObject) {
            $this->loadFrom($obj);
        } else {
            parent::setValue($value);
        }
        return $this;
    }
781007
public function setCoreUseMultibyte($value)
    {
        $this->setFieldName('use_multibyte');
        $this->loadObject(true);
        $this->setFieldValue($value);

        return $this;
    }
1292428
function cast($obj=NULL) {
		if (!$obj)
			$obj=$this;
		return array_map(
			function($row) {
				return $row['value'];
			},
			$obj->fields+$obj->adhoc
		);
	}
1018983
public function setValue($value = null)
    {

		if(isset($value)) {

			//ENT_QUOTES not set

			$this->value = array_map('htmlspecialchars', (array) $value);
		}

		foreach($this->options as $o) {

			$v = $this->getValue();

			if(is_array($v) && in_array($o->getValue(), $v)) {
				$o->select();
			}
			else {
				$o->unselect();
			}
		}
		
		return $this;

	}
705288
public function set($name, $value = UNDEFINED)
    {
        if (is_array($name)) {
            foreach ($name as $key => $val) {
                $this->set($key, $val);
            }

            return $this;
        }
        if ($name === false || $name === null) {
            return $this->reset();
        }

        // Verify if such a field exists
        if ($this->strict_fields && !$this->hasElement($name)) {
            throw $this->exception('No such field', 'Logic')
            ->addMoreInfo('name', $name);
        }

        if ($value !== UNDEFINED
            && (
                is_object($value)
                || is_object($this->data[$name])
                || is_array($value)
                || is_array($this->data[$name])
                || (string) $value != (string) $this->data[$name] // this is not nice..
                || $value !== $this->data[$name] // considers case where value = false and data[$name] = null
                || !isset($this->data[$name]) // considers case where data[$name] is not initialized at all
                                              //    (for example in model using array controller)
            )
        ) {
            $this->data[$name] = $value;
            $this->setDirty($name);
        }

        return $this;
    }
592828
public void setValue(Object obj, Object value) {
    if (setters.length > 0) {
      for (Method method : setters) {
        if (value == null || method.getParameterTypes()[0].isAssignableFrom(value.getClass())) {
          try {
            method.invoke(obj, value);
            return;
          } catch (IllegalAccessException | InvocationTargetException e) {
            // try to set field directly
          }
        }
      }
    }
    setFieldValue(field, obj, value);
  }
412209
public function assign($var, $value = null)
    {
        if (is_string($var)) {
            $this->_vars[$var] = $value;

            return $this;
        }

        if (is_array($var)) {
            foreach ($var as $key => $value) {
                if ($value instanceof AbstractClassContent) {
                    // trying to load subcontent
                    $subcontent = $this->getApplication()
                            ->getEntityManager()
                            ->getRepository(ClassUtils::getRealClass($value))
                            ->load($value, $this->getApplication()->getBBUserToken());
                    if (null !== $subcontent) {
                        $value = $subcontent;
                    }
                }

                $this->_vars[$key] = $value;
            }
        }

        return $this;
    }
1021201
public function onChange($value = null)
    {
        if (func_num_args()) {
            $this->onChange = $value;
            return $this;
        }
        return $this->onChange;
    }
85033
protected static function loadByMainField($value, $fields = null)
    {
        //
        $table = static::getTable();

        // get main field
        $field = static::getMainField();

        //
        $alias = static::getClassName();

        //
        $join = null;

        //
        $allFields = $fields ? $fields : static::getDefaultFields();

        // parse SQL select fields
        $selectFields = static::getDatabase()
                     ->getWriter()
                     ->selectFields($allFields, $alias, $join);

        //
        $token = ':'.$field;

        //
        $values = [$token => $value];

        // prepare SQL query
        $sql = " SELECT {$selectFields}"
             ."   FROM {$table} AS {$alias} {$join}"
             ."  WHERE {$field} = {$token}"
             .'  LIMIT 1';

        // fetch data on database and return it
        $object = static::fetch(
            $sql,
            $values,
            true,
            is_string($fields)
        );

        //
        return $object;
    }
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);
    }
374548
public function value($selector, $value = null)
    {
        if (is_null($value)) {
            return $this->resolver->findOrFail($selector)->getAttribute('value');
        }

        $selector = $this->resolver->format($selector);

        $this->driver->executeScript(
            "document.querySelector('{$selector}').value = '{$value}';"
        );

        return $this;
    }
545274
public function setValue($value, RequestAbstract $request)
    {
        if ($this->maxNumberOfSelection > 1) {
            $this->value = array();
            foreach ($value as $id) {
                if (!$this->dataSourceManager->has($id)) {
                    continue;
                }
                
                $this->value[] = $this->dataSourceManager->get($id);
            }
        } else {
            if (!$this->dataSourceManager->has($value)) {
                return;
            }
            
            $this->value = $this->dataSourceManager->get($value);
        }
    }
276467
function setValue($value) {
        $values = (array) $value;
        foreach ($values as $onevalue) {
            if (($this->tags || $this->ajax) &&
                    (!$this->optionExists($onevalue)) &&
                    ($onevalue !== '_qf__force_multiselect_submission')) {
                $this->addOption($onevalue, $onevalue);
            }
        }
        return parent::setValue($value);
    }
551577
public function setValue($value, $data = null)
    {
        // Define Value Property:
        
        $this->value = $value;
        
        // Determine Value Type:
        
        if (is_array($value)) {
            
            // Define from Array:
            
            foreach ($this->fields as $dim => $field) {
                
                if (isset($value[$dim])) {
                    $field->setValue($value[$dim]);
                }
                
            }
            
        } elseif ($value instanceof DBDimensions) {
            
            // Define from Field:
            
            foreach ($this->fields as $dim => $field) {
                $field->setValue($value->{$dim});
            }
            
        }
        
        // Answer Receiver:
        
        return $this;
    }
501105
public function setData($value) : Job
    {
        $this->validateJson($value);

        if ($this->data['data'] !== $value) {
            $this->data['data'] = $value;
            $this->setModified('data');
        }

        return $this;
    }
376060
public function with($key, $value = null)
    {
        if (is_array($key)) {
            $this->viewData = array_merge($this->viewData, $key);
        } else {
            $this->viewData[$key] = $value;
        }

        return $this;
    }
995726
public function loadChoiceList($value = null): ChoiceListInterface
    {
        $uomTypes = $this->uomTypeRepository->findAll();

        return new ArrayChoiceList($uomTypes, function ($ut) {
            $ut->getId();
        });
    }