title: scenario is taken correctly but does not work validation
body: <p>Hi I take user data to two models If the user clicks the checkbox (company) it show him the additional data that needs to complete. I needs to work on scenario if checbox = 1 the data fields of the form must be passed. It is my action from the controller:</p>
  
  <pre><code>public function actionCreate() {
          $model = new UrUserForm();
          $userDate = new UserDataForm();
          $model-&gt;scenario = 'create';
  
          if (($userDate-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $userDate-&gt;validate() &amp;&amp; $model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;validate()) || $model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;validate()) {
  
              if ($userDate-&gt;IsCompany()) {
                  $userDate-&gt;scenario = 'setFirm';
              } else {
                  $userDate-&gt;scenario = 'notFirm';
                  $userDate-&gt;clearData();
              }
              var_dump($userDate-&gt;scenario);
              exit();
              $userDate-&gt;saveOptionalData();
              $model-&gt;RoyalUserData=$userDate-&gt;data['Id'];
              $model-&gt;saveUser();
  
              Yii::$app-&gt;session-&gt;setFlash('success', 'Użytkownik został dodany');
              return $this-&gt;redirect(['index']);
          } else {
              return $this-&gt;render('create', [
                          'model' =&gt; $model,
                          'userDate' =&gt; $userDate
              ]);
          }
      }
  </code></pre>
  
  <p>An my model:</p>
  
  <pre><code>&lt;?php
  namespace backend\modules\users\models;
  
  use common\models\UserData;
  use frontend\modules\settings\models\Profile;
  
  use yii\base\Model;
  use Yii;
  
  class UserDataForm extends Model
  {
      public $Address;
      public $NIP;
      public $CompanyName;
      public $Website;
      public $Phone;
      public $IsCompany;
      public $IsPhoneConfirmed;
      public $CreatedAt;
      public $UpdateAt;
      public $Rel_State;
      public $Rel_Currency;
      public $IsDeleted;
      public $data;
  
      public function rules()
      {
          return [
              [['Address', 'Phone', 'Rel_State', 'Rel_Currency','IsCompany'], 'safe', 'on' =&gt; 'notFirm'],
              [['Address', 'Phone', 'Rel_State', 'Rel_Currency','IsCompany'], 'required', 'on' =&gt; 'setFirm'],
              [['NIP','IsCompany', 'Phone', 'IsPhoneConfirmed', 'CreatedAt', 'UpdateAt', 'Rel_State', 'Rel_Currency', 'IsDeleted'], 'integer'],
              [['Address', 'CompanyName', 'Website'], 'string', 'max' =&gt; 45],
              [['Phone'], 'common\components\validators\PhoneValidator'], 
              [['NIP'], 'common\components\validators\NipValidator'],
              ['IsCompany', 'safe']
          ];
      }
  
      public function scenarios()
      {
          $scenarios = parent::scenarios();
          $scenarios['setFirm'] = ['Address', 'Phone', 'Rel_State', 'Rel_Currency','IsCompany'];
          $scenarios['notFirm'] = ['Address', 'Phone', 'Rel_State', 'Rel_Currency','IsCompany'];
          return $scenarios;
      }
  
       public function saveOptionalData() {
  
          $model = new UserData();
          $model-&gt;Address=$this-&gt;Address;
          $model-&gt;Phone=$this-&gt;Phone;
          $model-&gt;Rel_State=$this-&gt;Rel_State;
          $model-&gt;Rel_Currency= $this-&gt;Rel_Currency;
          $model-&gt;NIP=$this-&gt;NIP;
          $model-&gt;IsCompany = $this-&gt;IsCompany;
          $model-&gt;IsPhoneConfirmed = $this-&gt;IsPhoneConfirmed;
          $model-&gt;CompanyName = $this-&gt;CompanyName;
          $model-&gt;Website = $this-&gt;Website;
          $this-&gt;data=$model;
          if ($model-&gt;validate() &amp;&amp; $model-&gt;save()) {
              return $model;
          }
          return false;
      }
  
      public function clearData() {
          $this-&gt;Address = NULL;
          $this-&gt;Phone = NULL;
          $this-&gt;Rel_State = NULL;
          $this-&gt;Rel_Currency = NULL;
          $this-&gt;NIP = NULL;
          $this-&gt;IsCompany = NULL;
          $this-&gt;IsPhoneConfirmed = NULL;
          $this-&gt;CompanyName = NULL;
          $this-&gt;Website = NULL;
      }
  
      public function IsCompany() {
  
          if ($this-&gt;IsCompany == 1) {
              return true;
          }
          return false;
      }
      }
  </code></pre>
  
  <p>I read the documentation but it does not help me. In the create action I created </p>
  
  <blockquote>
    <p>var_dump($userDate->scenario);
                exit();</p>
  </blockquote>
  
  <p>which indicates that there is everything okay because when checkobox is off  vardump spits: string (7) "notFirm" and when he's on spits: string (7) "setFirm." I do not know where the fault but each time validation is safe, that should work that if checkbox is on data from rules(addres, phone) should be required. Anyone see my bad and can help me?</p>