<?php if(isset($model->file->filename)){ ?>
<?= $form->field($model->file, 'filename')->textInput(); ?>
<?php }else{ ?>
<?= $form->field($files, 'filename')->textInput(); ?>
<?php } ?>
if ($model->load($request->post())) {
$model->file_id = $files->id;
$model->save();
$files->save();
<?= $form->field($model, 'variable')->textInput(); ?>
if ($model->load($request->post()) && $model->save(false)) {
$f = Files::findOne(['id' => $model->file_id]);
$f->filename = $model->variable;
$f->save();
Спасибо