Yii2 kartik fileinput change value image dynamically

559 Views Asked by At

I'm using kartik fileinput extension and i want to put a radio button for each picture so the user can select the necessary photo, my code in view is:

<?= $form->field($model, 'imageFiles[]')->widget(FileInput::classname(), [

    'options' => ['multiple' => true, 'accept' => 'image/*', 'id'=>'inputFile'],

    'pluginOptions' => [
        'layoutTemplates' => ['preview'=>

            "    <div class='file-preview-thumbnails'>\n" .
            "    </div>\n" .
            "    <div class='clearfix'></div>" .
            "    <div class='file-preview-status text-center text-success'></div>\n".
            "    <div class='kv-fileinput-error'></div>\n",

            'footer' => "<div class=\'file-thumbnail-footer\'>\n" .
                "    <div class='file-caption-name' style='width:{width}'>{caption}</div>\n" .
                "    {progress} {actions}" .
                '<div><br>
                                                <div class="radio-btn">

                                                <input type="radio" value={caption} id="rc1" name="rc1" checked="checked">

                                                <label for="rc1" onclick><span class="label label-default" style="font-size: 1em;">Main image</span></label>

                                                </div></div>'.
                "</div>"
        ],
        'uploadUrl' => '/ads/create',
        'maxFileCount' => 4,
        'showUpload' => false,
        'showCaption' => false,
        'showClose' => false,
    ]
]);
?>

I want <input type="radio" value={caption} id="rc1"> change to <input type="radio" value=FILENAME id="rc1"> depending on any file that is selected, Please guide me, thanks.

0

There are 0 best solutions below