setAttributes() public method

Sets the attribute values in a massive way.
See also: safeAttributes()
See also: attributes()
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 = [];
     }
 }
Beispiel #2
0
 /**
  * Override
  */
 public function setAttributes($values, $safeOnly = true)
 {
     parent::setAttributes($values, $safeOnly);
     if ($this->roles === "") {
         $this->roles = [];
     }
 }
Beispiel #3
0
 /**
  * @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);
         }
     }
 }
Beispiel #4
0
 /**
  * @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;
 }
Beispiel #6
0
 public function setAttributes($values, $safeOnly = false)
 {
     parent::setAttributes($values, $safeOnly);
 }