M
M
Mikha Pankratov2015-04-05 02:44:59
Yii
Mikha Pankratov, 2015-04-05 02:44:59

Yii2 how to use foreach to display multiple images in a widget?

The people of Google are already screaming from my requests) I
use the FileInput Widget / cool thing.
So I came to the conclusion that it is required to display a lot of already loaded previews.

<?= $form->field($model, 'image[]')->widget(FileInput::classname(), [
    'options' => ['accept' => 'image/*', 'multiple' => true,],
    'pluginOptions' => [
        'initialPreview'=>[
// вот тут я хочу foreach перебрать все фотки Preview 
           //foreach($photos as $photo){
                Html::img("/images/".$photo->name, ['class'=>'file-preview-image', 'alt'=>'The Moon', 'title'=>'The Moon']),
            //}
        ],
    ],
])->label(false);

I just don’t like foreach, maybe there is some other input there? Who did this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rikcon, 2015-04-05
@frmax

Collect the array you want to shove into the initialPreview in the controller, and feed it to the same InitialPreview.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question