title: How to implement kartik yii2 FileInput in form which is using different model
body: <p>Here is the code located in myyiiapp\backend\views\product_form.php</p>
  
  <pre><code>&lt;?php
  
  use yii\helpers\Html;
  use yii\widgets\ActiveForm;
  use kartik\widgets\FileInput;
  
  /**
   * @var yii\web\View $this
   * @var backend\models\Product $model
   * @var yii\widgets\ActiveForm $form
   */
  ?&gt;
  
  &lt;div class="product-form"&gt;
  
      &lt;?php $form = ActiveForm::begin(); ?&gt;
  
      &lt;?= $form-&gt;field($model, 'category_id')-&gt;textInput() ?&gt;
  
      &lt;?= $form-&gt;field($model, 'name')-&gt;textInput(['maxlength' =&gt; 255]) ?&gt;
  
      &lt;?= $form-&gt;field($model, 'description')-&gt;textarea(['rows' =&gt; 6]) ?&gt;
  
      &lt;?= $form-&gt;field($model, 'created')-&gt;textInput() ?&gt;
  
      &lt;?= $form-&gt;field($model, 'last_updated')-&gt;textInput() ?&gt;
  
      &lt;?= $form-&gt;field($model, 'documentation')-&gt;textInput(['maxlength' =&gt; 255]) ?&gt;
  
      &lt;?= $form-&gt;field($model, 'layout')-&gt;textInput() ?&gt;
  
      &lt;?=
      // Usage with ActiveForm and model
       $form-&gt;field($model, 'someAttributeName')-&gt;widget(FileInput::classname(), [
          'options' =&gt; ['accept' =&gt; 'image/*'],
      ]);
  
      ?&gt;
  
      &lt;div class="form-group"&gt;
          &lt;?= Html::submitButton($model-&gt;isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' =&gt; $model-&gt;isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?&gt;
      &lt;/div&gt;
  
      &lt;?php ActiveForm::end(); ?&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>I have a table name "<strong>product</strong>" and I have another table name "<strong>product_images</strong>" which contain product image path and product id column.</p>
  
  <p>How can I set attribute where it says <strong>someAttributeName</strong> for image which is in ProductImage model and this form is using <strong>Product</strong> model. In short how can we use multiple model in here and I need to create product first then image path because to save image path I need product id which is going to be auto generated by mysql.</p>
  
  <p>I have generated everything from Yii2 crud.</p>