kartik-v / yii2-widget-fileinput

An enhanced FileInput widget for Bootstrap 4.x/3.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)
Other
229 stars 96 forks source link

otherActionButtons: {downloadUrl} not replaced with downloadUrl #151

Closed jokamax closed 5 years ago

jokamax commented 5 years ago

Steps to reproduce the issue

I use otherActionButtons in my widget. {dataKey} no problem. {caption} no problem. But impossible to use {downloadUrl} => not replaced

My code :

$btns = '<button type="button" class="kv-cust-btn btn btn-default" title="Utiliser en tant qu\'avatar"{dataKey}>' .
    '<i class="fas fa-user-astronaut"></i>{downloadUrl}' .
    '</button>';
// your fileinput widget for single file upload
echo $form->field($model, 'file')->widget(FileInput::classname(), [
    'options'=>['accept'=>'image/*'],
    'pluginOptions' => [
                'deleteUrl' => 'file/delete',
                'allowedFileExtensions'=>['jpg', 'jpeg', 'gif','png'],
                'previewFileType' =>  "image",

                'initialPreview'=>[
                    "http://upload.wikimedia.org/wikipedia/commons/thumb/e/e1/FullMoon2010.jpg/631px-FullMoon2010.jpg",
                    "http://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Earth_Eastern_Hemisphere.jpg/600px-Earth_Eastern_Hemisphere.jpg"
                ],
                'initialPreviewAsData'=>true,
                'initialCaption'=>"Cliquez sur parcourir pour ajouter un avatar, puis transférer...",
                'initialPreviewConfig' => [
                    ['caption' => 'Moon.jpg', 'size' => '873727', 'key' => '1', 
                    'downloadUrl' =>  "http://upload.wikimedia.org/wikipedia/commons/thumb/e/e1/FullMoon2010.jpg/631px-FullMoon2010.jpg"],
                    ['caption' => 'Earth.jpg', 'size' => '1287883', 'key' => '2' ,
                    'downloadUrl'=> "http://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Earth_Eastern_Hemisphere.jpg/600px-Earth_Eastern_Hemisphere.jpg"],
                ],
                'overwriteInitial'=>false,
                'maxFileSize'=>100,
                'otherActionButtons' => $btns,
            ]
])->label(false);

Result display "{downloadUrl}". Test is dirty only for testing purpose ;)

Expected behavior and actual behavior

When I follow those steps, I see...

I was expecting...

Environment

Browsers

Operating System

Libraries

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.