D
D
daashuun2020-11-25 03:06:07
Yii
daashuun, 2020-11-25 03:06:07

How to set fileInput to default value?

The ActiveForm has a fileInput that is created from the model, in which the value of this input may already be set. The question is how to make it see this value when submitting the form? If I prescribe it as an attribute in value, then the value is assigned, but it cannot pass validation, it says that the field needs to be filled.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timofey, 2020-12-02
@Timoffeus

The solution depends on how the images are stored on the server.
Upd.

<?= $form->field($model, 'Foo')->input('bar', ['value' => !empty($model->Image) ? $model->image : false]) ?>

Something like this, purely on the knee

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question