title: validate model depending radio button selected
body: <p>I have install yii-user extension and add some column in tbl_profile table for registration. Registration type are two type: Personal and company</p>
  
  <p><strong>following are the column added:</strong></p>
  
  <p><strong>For company</strong>: company_name, comoany_type</p>
  
  <p><strong>For personal</strong>: phone</p>
  
  <p><strong>For both personal and company</strong>:  mobile, fullname, country, states, postal_code, address1, address2</p>
  
  <p>I have use jquery to hide and disable the input field of form according to radio button selection of registration type. </p>
  
  <p>Same goes for country selection for both registration type. Two Options: e.g USA and other country  </p>
  
  <p>I am confused that how can I validate the property according to the registration type selected. e.g. If I select the personal then disable the validation for the company property field.</p>
  
  <p>There are two models with their property:</p>
  
  <p><strong>Profile</strong>:  fullname, company_name, company_type, mobile, phone, firstaddress, secondaddress, country, states, postal_code</p>
  
  <p><strong>RegistrationForm</strong>: username, password, email</p>
  
  <p>I have also define rules for those property on corresponding model.</p>
  
  <p>I have tried validating model like this but doesn't works:</p>
  
  <pre><code>if(isset($_POST['RegistrationForm'])) {
      if($_POST['Profile']['account_type'] == 'personal')
      {
          //for personal account
          $profile-&gt;account_type = $_POST['Profile']['account_type'];
          $model-&gt;username = $_POST['RegistrationForm']['username'];
          $model-&gt;password = $_POST['RegistrationForm']['password'];
          $model-&gt;verifyPassword = $_POST['RegistrationForm']['verifyPassword'];
          $model-&gt;email = $_POST['RegistrationForm']['email'];
          $model-&gt;verifyCode = $_POST['RegistrationForm']['verifyCode'];
          $model-&gt;accept = $_POST['RegistrationForm']['accept'];
          $profile-&gt;fullname = $_POST['Profile']['fullname'];
          $profile-&gt;phone = $_POST['Profile']['phone'];
          $profile-&gt;ext = $_POST['Profile']['ext'];
          $profile-&gt;mobile = $_POST['Profile']['mobile'];
          if($_POST['choose_country'] == 'other')
          {
              $profile-&gt;country = $_POST['choose_country'];
              $profile-&gt;states = $_POST['profile_states'];
              $profile-&gt;postalcode = $_POST['Profile']['postalcode'];
              $profile-&gt;firstaddress = $_POST['Profile']['firstaddress'];
              $profile-&gt;secondaddress = $_POST['Profile']['secondaddress'];
          }
          if($_POST['choose_country'] == 'Nepal')
          {
              $profile-&gt;country = $_POST['choose_country'];
              $profile-&gt;firstaddress = $_POST['Profile']['firstaddress'];
              $profile-&gt;secondaddress = $_POST['Profile']['secondaddress'];
          }
      }
      if($_POST['Profile']['account_type'] == 'company')
      {
          //for organization account
          $profile-&gt;account_type = $_POST['Profile']['account_type'];
          $model-&gt;username = $_POST['RegistrationForm']['username'];
          $model-&gt;password = $_POST['RegistrationForm']['password'];
          $model-&gt;verifyPassword = $_POST['RegistrationForm']['verifyPassword'];
          $model-&gt;email = $_POST['RegistrationForm']['email'];
          $model-&gt;verifyCode = $_POST['RegistrationForm']['verifyCode'];
          $model-&gt;accept = $_POST['RegistrationForm']['accept'];
          $profile-&gt;fullname = $_POST['Profile']['fullname'];
          $profile-&gt;ext = $_POST['profile']['ext'];
          $profile-&gt;mobile = $_POST['Profile']['mobile'];
          $profile-&gt;company_name = $_POST['Profile']['company_name'];
          $profile-&gt;company_type = $_POST['Profile']['company_type'];
          $profile-&gt;designation = $_POST['Profile']['designation'];
  
          if($_POST['choose_country'] == 'Nepal')
          {
              $profile-&gt;country = $_POST['choose_country'];
              $profile-&gt;states = $_POST['Profile']['states'];
              $profile-&gt;postalcode = $_POST['Profile']['postalcode'];
              $profile-&gt;firstaddress = $_POST['profile']['firstaddress'];
              $profile-&gt;secondaddress = $_POST['profile']['secondaddress'];
          }
          if($_POST['choose_country'] == 'others')
          {
              $profile-&gt;country = $_POST['profile']['country'];
              $profile-&gt;firstaddress = $_POST['profile']['firstaddress'];
              $profile-&gt;secondaddress = $_POST['profile']['secondaddress'];
          }
      }
  
      //$model-&gt;attributes=$_POST['RegistrationForm'];
      //$profile-&gt;attributes=((isset($_POST['Profile'])?$_POST['Profile']:array()));
  
      if($model-&gt;validate()&amp;&amp;$profile-&gt;validate())
      {
      }
  }
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>If I select the personal radio button and submit form it still validate the company_name , company type and same for country selection then shows the validation errors. Here what I want is to disable the validation of model depending on selection of radio button either personal or company type.</p>