setAttributes() публичный Метод

Sets the attribute values in a massive way.
См. также: safeAttributes()
См. также: 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]].
Пример #1
0
 /**
  * @inheritdoc
  */
 public function setAttributes($values, $safeOnly = true)
 {
     parent::setAttributes($values, $safeOnly);
     if (empty($this->images)) {
         $this->images = [];
     }
 }
Пример #2
0
 /**
  * Override
  */
 public function setAttributes($values, $safeOnly = true)
 {
     parent::setAttributes($values, $safeOnly);
     if ($this->roles === "") {
         $this->roles = [];
     }
 }
Пример #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);
         }
     }
 }
Пример #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;
 }
Пример #6
0
 public function setAttributes($values, $safeOnly = false)
 {
     parent::setAttributes($values, $safeOnly);
 }