title: Yii2: ActiveRecord How to unload / unset a model of all(some) attributes?
body: <p>Yii2 ActiveRecord has a method to automatically load a form data into a model using <a href="http://www.yiiframework.com/doc-2.0/yii-base-model.html#load%28%29-detail" rel="nofollow"><code>load()</code></a>  which is very good as it safely loads the model with data, However I am not able find a equivalent method to unload the model of all the attributes.</p>
  
  <p>i.e. Is there a method to unset all attributes of a model in Yii2, like the <a href="http://www.yiiframework.com/doc/api/1.1/CModel#unsetAttributes-detail" rel="nofollow"><code>unSetAttributes()</code></a> method in Yii 1.x ?</p>
  
  <p>Currently the only way to do this seems to be either </p>
  
  <pre><code>$model-&gt;setAttributes(['attribute1'=&gt;NULL,'attribute2' =&gt; NULL ... ]);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>foreach ($model-&gt;attributes as $attribute) {
      $model-&gt;$attribute = NULL; 
  }
  </code></pre>
  
  <p><strike><strong>Edit</strong>: To clarify in response to <a href="https://stackoverflow.com/a/25132137/1900483">Samuel Liew's answer</a>, while at this point I only wanted to unset all attributes which I could do by reiniting the model, I would also like to control which attributes are getting reset, which <code>unSetAttributes</code> provided </strike></p>