Sets the attribute values in a massive way.
public setAttributes ( array $values, boolean $safeOnly = true ) | ||
$values | array | attribute values (name => value) to be assigned to the model. |
$safeOnly | boolean | whether the assignments should only be done to the safe attributes. A safe attribute is one that is associated with a validation rule in the current [[scenario]]. |
/** * @inheritdoc */ public function setAttributes($values, $safeOnly = true) { parent::setAttributes($values, $safeOnly); if (empty($this->images)) { $this->images = []; } }
/** * Override */ public function setAttributes($values, $safeOnly = true) { parent::setAttributes($values, $safeOnly); if ($this->roles === "") { $this->roles = []; } }
/** * @inheritdoc */ public function setAttributes($values, $safeOnly = true) { parent::setAttributes($values, $safeOnly); if (true === is_array($values)) { foreach ($values as $k => $v) { $event = new app\modules\shop\events\UserPreferenceEvent($k, $v); $this->trigger(static::EVENT_SET_ATTRIBUTE, $event); } } }
/** * @param array $values * @param bool|true $safeOnly * @return $this */ public function setAttributes($values, $safeOnly = true) { parent::setAttributes($values, $safeOnly); return $this; }
/** * Fills model attributes with previous saved state * @param $values array of state form file * @return bool result */ public function loadAttributesFromState($values) { parent::setAttributes($values, false); return true; }
public function setAttributes($values, $safeOnly = false) { parent::setAttributes($values, $safeOnly); }