Sets a field to the record.

@param $name
@param $value
@return mixed

@throws \Exception
762019
public function setField($name, $value) {
    if (isset($this->fields[$name])) {
      $this->isDirty = TRUE;

      return $this->record[$name] = $value;
    }
    throw new \Exception('Not a valid Field for Set ' . $name);
  }
775199
public function field(string $name, Syntax $value = null)
    {
        if ($value === null) {
            $names = explode('.', $name);
            $syntax = $this;
            foreach ($names as $field) {
                while (method_exists($syntax, 'syntax')) {
                    $syntax = $syntax->syntax();
                }
                if ($syntax instanceof ObjectSyntax && array_key_exists($field, $syntax->fields)) {
                    $syntax = $syntax->fields[$field];
                } else {
                    throw new \InvalidArgumentException("field '{$name}' not found");
                }
            }
            return $syntax;
        }

        $this->fields[$name] = $value;
        return $this;
    }
573831
public function getField($name)
    {
        if (empty($this->form)) {
            throw new Exception(['Incorrect value for $form', 'form' => $this->form]);
        }

        return $this->form->getField($name);
    }
1307233
public function setAttribute($name, $value)
    {
        $primaryKeyNames = self::getPrimaryKeyName(true);

        $meta = self::getMeta();
        $name = $meta->getMappingName($name);

        if ($meta->hasField($name)) {
            $field = $meta->getField($name);
            $attributeName = $field->getAttributeName();

            if ($field->getSqlType()) {
                $platform = $this->getConnection()->getDatabasePlatform();
                $value = $field->convertToDatabaseValueSQL($value, $platform);

                if (in_array($attributeName, $primaryKeyNames)) {
                    // If new primary key is empty - mark model as new
                    if (empty($value)) {
                        $this->setIsNewRecord(true);
                    } elseif ($this->getAttribute($attributeName) != $value) {
                        // If current model isn't new and new primary key value != new value - mark model as new
                        $this->setIsNewRecord(true);
                    }
                }

                $this->attributes->setAttribute($attributeName, $value);
            } else {
                $this->related[$name] = $value;
            }
        } else {
            throw new Exception(get_class($this).' has no attribute named "'.$name.'".');
        }
    }
1345357
public function setField($field, $value = '')
    {
        if (is_array($field)) {
            $data = $field;
        } else {
            $data[$field] = $value;
        }
        return $this->update($data);
    }
1179361
public function set($name, $value)
    {
        $this->_vars[$name] = is_object($value) ? $value->fetch() : $value;
    }
6154
public function setSetting( $name, $value )
    {
        $old = isset( $this->settings[$name] )
            ? $this->settings[$name]
            : null;

        if ( $old instanceof self || $value instanceof self )
        {
            if ( $old instanceof self && $value instanceof self )
            {
                $old->setSettings( $value->settings );
            }
            else if ( $old instanceof self )
            {
                if ( $value instanceof Traversable )
                {
                    $value = ArrayUtils::iteratorToArray( $value );
                }

                $old->setSettings( (array) $value );
            }
            else
            {
                $this->settings[$name] = $value;
            }
        }
        else
        {
            $method = array( $this, 'update' . ucfirst( $name ) );

            if ( is_callable( $method ) &&
                 ( ( isset( $value )    && isset( $this->settings[$name] )
                                        && $value != $this->settings[$name] ) ||
                   ( isset( $value )    && ! isset( $this->settings[$name] ) ) ||
                   ( ! isset( $value )  && isset( $this->settings[$name] ) ) ) )
            {
                $value = $method( $value, $old );
            }

            if ( null === $value )
            {
                unset( $this->settings[$name] );
            }
            else
            {
                $this->settings[$name] = $value;
            }
        }

        return $this;
    }
293299
public function set($name, $value = null)
    {
        if (is_string($name)) {
            $name = $this->cleanAttributeName($name);
            if ($value === null && isset($this->props[$name])) {
                unset($this->props[$name]);
            } elseif ($value !== null) {
                $this->props[$name] = $value;
            }
        }

        return $this;
    }
128315
public function offsetSet($name, $value)
    {
        if(array_key_exists($name, $this->services) && !isset($this->mutables[$name]))
            throw new \Exedra\Exception\Exception('['.get_class($this).'] Service ['.$name.'] is publically immutable and readonly once assigned.');

        $this->services[$name] = $value;

        $this->services['service']->set($name, true);
    }
1236813
protected static function formatFieldValue($name, $value) {
		$field	= static::$validator->getField($name);
		if( $field ) {
			$field->getType()->formatValue($field, $value);
		}
		return parent::formatFieldValue($name, $value);
	}
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;
    }
320855
public function set($name, $value)
    {
        try {
            if (is_string($name) && (is_string($value) || $value === null)) {
                if ($value === null) {
                    if (!array_key_exists($name, $this->defaults)) {
                        return false;
                    }
                    $value = $this->defaults[$name];
                }
                if ((new Query)->from(static::tableName())->where(['name' => $name])->exists()) {
                    Podium::getInstance()->db->createCommand()->update(
                        static::tableName(), ['value' => $value], ['name' => $name]
                    )->execute();
                } else {
                    Podium::getInstance()->db->createCommand()->insert(
                        static::tableName(), ['name' => $name, 'value' => $value]
                    )->execute();
                }
                $this->cache->set('config', $this->notCached);
                $this->_config = null;
                return true;
            }
        } catch (Exception $e) {
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }
223142
public function set($name, $value)
	{
		list($class, $name) = explode('::$', $name, 2);

		$class = new \ReflectionClass($class);
		$property = $class->getProperty($name);
		$property->setAccessible(TRUE);
		$property->setValue(NULL, $value);
	}
1126389
function setParameter($name, $value)
    {
        $this->field = $name;
        $this->descending = boolval($value);
        return $this;
    }
1343369
public function setField($name, $key, $value)
    {
        if (!array_key_exists($name, $this->fields)) {
            $this->fields[$name] = [];
        }
        $this->fields[$name][$key] = $value;
    }
1018519
public function set($name, $value = UNDEFINED)
    {
        if (is_array($name)) {
            foreach ($name as $key => $val) {
                $this->set($key, $val);
            }

            return $this;
        } elseif ($value === UNDEFINED) {
            throw $this->exception('You must define the second argument');
        }

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

        if (($value !== $this->data[$name]) || (is_null($value) && !array_key_exists($name, $this->data))) {
            $this->data[$name] = $value;
            $this->setDirty($name);
        }

        if ($name === $this->id_field) {
            $this->id = $value;
        }

        return $this;
    }
341843
public function set($field, $value = UNDEFINED)
    {
        if ($value === false) {
            throw $this->exception('Value "false" is not supported by SQL')
                ->addMoreInfo('field', $field);
        }
        if (is_array($field)) {
            foreach ($field as $key => $value) {
                $this->set($key, $value);
            }

            return $this;
        }

        if ($value === UNDEFINED) {
            throw $this->exception('Specify value when calling set()');
        }

        $this->args['set'][$field] = $value;

        return $this;
    }