title: yii2 How to change user password via actionUpdate?
body: <p>I have advanced app. I create CRUD for User model. So i got update action. I tried to update password by adding </p>
  
  <pre><code>&lt;?= $form-&gt;field($model, 'password')-&gt;passwordInput() ?&gt;
  </code></pre>
  
  <p>But it call error, something like "password is write-only variable"</p>
  
  <p>I tried to use field</p>
  
  <pre><code>&lt;?= $form-&gt;field($model, 'new_password')-&gt;passwordInput() ?&gt;
  </code></pre>
  
  <p>With adding in actionUpdate <code>model-&gt;setPassword($this-&gt;new_password);</code> and it throw <code>Getting unknown property: common\modules\user\controllers\DefaultController::new_password</code>.
  But <code>model-&gt;setPassword('123456');</code> successfully setting pussword <code>123456</code>.</p>
  
  <p>How can i get <code>new_password</code> field from view, to put it in <code>model-&gt;setPassword('there');</code></p>
  
  <p>Or maybe exist best way to do it?</p>
  
  <p><strong>UPD</strong></p>
  
  <p>I tried do it. Is not work.</p>
  
  <pre><code>  public function beforeSave($insert)
    {
      if (parent::beforeSave($insert)) {
        if ($this-&gt;new_password) {
          $this-&gt;setPassword($this-&gt;new_password);
        }
        return true;
      } else {
        return false;
      }
    }
  </code></pre>
  
  <p><strong>UPD2</strong></p>
  
  <pre><code>  public function setPassword($password) {
      $this-&gt;password_hash = Yii::$app-&gt;security-&gt;generatePasswordHash($password);
    }
  </code></pre>
  
  <p>And password_hash writing in database. I can easy change hash, via generated CRUD, but don't know how to use <code>setPassword()</code> in updateAction.</p>