title: Yii2: how to use two models in one view?
body: <p>I have a model called <strong>Person.php</strong> and a model called <strong>Country.php</strong>.
  Then I have the view <strong>Persons/create.php</strong></p>
  
  <p>I included the model of the countries and I called <strong>$modelCountry</strong> but is it not working. I got the error:</p>
  
  <blockquote>
    <p>Undefined variable: modelCountry</p>
  </blockquote>
  
  <p>This is the <strong>model/Persons.php</strong> file.</p>
  
  <pre><code>&lt;?php
  use yii\helpers\ArrayHelper;
  use yii\helpers\Html;
  use yii\widgets\ActiveForm;
  
  /* @var $this yii\web\View */
  /* @var $model app\models\Person */
  /* @var $modelCountry app\models\Country */
  
  ?&gt;
  &lt;div class="person-create"&gt;
  
      &lt;?php $form = ActiveForm::begin(); ?&gt;
          &lt;?= $form-&gt;field($model, 'phone')-&gt;textInput() ?&gt;
          &lt;?= $form-&gt;field($modelCountry, 'name')-&gt;textInput() ?&gt;
  
          &lt;?= Html::submitButton($model-&gt;isNewRecord ? 'Create') ?&gt;
  
      &lt;?php ActiveForm::end(); ?&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Then I want to use the send button to send both models to the controller (controllers/PersonsController.php)</p>