title: Yii2 FileInput - Trying to get property of non object
body: <p>i am using Yii2 and Kartik's FileInput extension and I have successfully get the file uploads working(only single upload). My problem now is that, I get the error as in the title(with logs attached) if I did not choose any files(It should be optional).</p>
  
  <p>After much searching over the internet, I think it has to be something to do with array, but I am not sure how to fix that, especially even with the logs pointing to the exact line!</p>
  
  <p>Here is my log,</p>
  
  <p><a href="https://i.stack.imgur.com/d8iqc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d8iqc.png" alt="log"></a></p>
  
  <p>Here is my model,
      
  
  <pre><code>namespace app\models;
  
  use Yii;
  
  class FormMovement extends \yii\db\ActiveRecord
  {
  
      public $file;
  
      public static function tableName()
      {
          return 'form_movement';
      }
  
      public function rules()
      {
          return [
              [['fm_date_received', 'fm_form_name', 'fm_from', 'fm_ptj'], 'required'],
              [['form_id'], 'integer'],
              [['fm_date_received', 'fm_date_action1', 'fm_date_action2','fm_upload'], 'safe'],
              [['fm_form_name', 'fm_note'], 'string', 'max' =&gt; 500],
              [['fm_from', 'fm_ptj', 'fm_action1', 'fm_action2'], 'string', 'max' =&gt; 100],
              [['file'], 'file', 'skipOnEmpty' =&gt; true, 'extensions'=&gt;'jpg,pdf,png,doc,docx,xls,xlsx, jpeg', 'maxFiles' =&gt; 3],
          ];
      }
  </code></pre>
  
  <p>My controller function, the log shows that it is at the line 75, which is this one,</p>
  
  <pre><code>$model-&gt;fm_upload='uploads/'.$fileName.'.'.$model-&gt;file-&gt;extension;
  </code></pre>
  
  <p>Been tinkering with it, but no success.</p>
  
  <pre><code>public function actionCreate()
      {
          $model = new FormMovement();
  
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post())) {
  
              //set the file name
              $fileName = $model -&gt; fm_form_name;
  
              //get instance
              $model-&gt;file = UploadedFile :: getInstance($model, 'file');
  
              //set the file path in the db
              $model-&gt;fm_upload='uploads/'.$fileName.'.'.$model-&gt;file-&gt;extension;
  
              //save the file to the server directory
              $model-&gt;save();
              $model-&gt;file-&gt;saveAs('uploads/'.$fileName.'.'.$model-&gt;file-&gt;extension);
  
              return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;form_id]);
          } else {
              return $this-&gt;render('create', [
                  'model' =&gt; $model,
              ]);
          }
      }
  </code></pre>
  
  <p>Finally my view,</p>
  
  <pre><code>&lt;div class="form-group kv-fieldset-inline"&gt;
      &lt;?= Html::activeLabel($model, 'file[]', [
              'label'=&gt;'MUAT NAIK FAIL',
              'class'=&gt;'col-sm-1 control-label'
          ]) ?&gt;
  
      &lt;div class="col-sm-8"&gt;
      &lt;?= $form-&gt;field($model, 'file',[
                  'showLabels'=&gt;false
              ])-&gt;widget(FileInput::classname(), [
              'options' =&gt; ['accept' =&gt; 'file/*', 'multiple' =&gt; 'true'],
              'pluginOptions'=&gt;[
                  'showUpload' =&gt; false,
              ]
      ]) ?&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>