title: Yii2 create two signup form?
body: <p>I have to create 2 signup form for different user but,I have use one table for both signup form. table is 'User' but in both form some field are different and table is same for both.But when I validate first form that time second form also validate.please help me I am new in yii2.</p>
  
  <pre><code>&lt;?php $form = ActiveForm::begin(['id' =&gt; 'form-signup']); ?&gt;
  
                      &lt;?= $form-&gt;field($model, 'username') ?&gt;
  
                      &lt;?= $form-&gt;field($model, 'email') ?&gt;
  
                      &lt;?= $form-&gt;field($model, 'password')-&gt;passwordInput() ?&gt;
  
                      &lt;div class="form-group"&gt;
                      &lt;button type = "submit" class = "btn btn-primary pull-right"&gt;
                      &lt;strong&gt;Signup User&lt;/strong&gt;
                      &lt;/button&gt;
  
                      &lt;/div&gt;
  
                  &lt;?php ActiveForm::end(); ?&gt;
  &lt;?php $form = ActiveForm::begin(['id' =&gt; 'form-signup']); ?&gt;
  
                      &lt;?= $form-&gt;field($model2, 'fname') ?&gt;
                      &lt;?= $form-&gt;field($model2, 'mname') ?&gt;
                      &lt;?= $form-&gt;field($model2, 'lname') ?&gt;
                      &lt;?= $form-&gt;field($model2, 'username') ?&gt;
                      &lt;?= $form-&gt;field($model2, 'email') ?&gt;
                      &lt;?= $form-&gt;field($model2, 'password')-&gt;passwordInput() ?&gt;  
                      &lt;?= $form-&gt;field($model2, 'designation') ?&gt; 
                      &lt;?= $form-&gt;field($model2, 'contact_no') ?&gt;
  &lt;button type = "submit" class = "btn btn-success pull-right"&gt;
               &lt;strong&gt;Signup Vendor&lt;/strong&gt;
               &lt;/button&gt;
                &lt;?php ActiveForm::end(); ?&gt;
  public function rules()
      {
          return [
              ['username', 'filter', 'filter' =&gt; 'trim'],
              ['username', 'required'],
              ['fname', 'required'],
              ['mname', 'required'],
              ['lname', 'required'],
              ['username', 'unique', 'targetClass' =&gt; '\common\models\User', 'message' =&gt; 'This username has already been taken.'],
              ['username', 'string', 'min' =&gt; 2, 'max' =&gt; 255],
  
              ['email', 'filter', 'filter' =&gt; 'trim'],
              ['email', 'required'],
              ['email', 'email'],
              ['email', 'string', 'max' =&gt; 255],
              ['email', 'unique', 'targetClass' =&gt; '\common\models\User', 'message' =&gt; 'This email address has already been taken.'],
  
              ['password', 'required'],
              ['password', 'string', 'min' =&gt; 6],
              ['designation', 'required'],
              ['designation', 'string', 'max' =&gt; 100],
              ['contact_no', 'required'],
              ['contact_no', 'number', 'max' =&gt; 12],
          ];
      }
  public function actionSignup()
      {
          $model = new SignupForm();
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post())) {
              if ($user = $model-&gt;signup()) {
                  return $this-&gt;redirect(['login']);
                  if (Yii::$app-&gt;getUser()-&gt;login($user)) {
                  }
              }
          }
         $model2 = new SignupForm2();
          if ($model2-&gt;load(Yii::$app-&gt;request-&gt;post())) {
              if ($user = $model2-&gt;signup()) {
                  return $this-&gt;redirect(['login']);
                  if (Yii::$app-&gt;getUser()-&gt;login($user)) {
                  }
              }
          }
          return $this-&gt;render('signup', [
              'model' =&gt; $model,
              'model2' =&gt; $model2,
          ]);
      }
  </code></pre>
  
  <p>Now It's Work,I am create 2 <strong>signupForm.php</strong> in front end models.and in <strong>siteController</strong> create two models in <strong>actionSignup</strong>
   <a href="https://i.stack.imgur.com/WfHAZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WfHAZ.png" alt="enter image description here"></a>validate </p>