0

我想用单选按钮标记图像并将其发送到表单中,我需要此按钮的值是该图像的名称,我的代码是:

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

    'options' => ['multiple' => true, 'accept' => 'image/*', 'id'=>'inputFile'],
    'pluginOptions' => [
        layoutTemplates' => [
            '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" "id="rc1" name="rc1" checked="checked">

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

 </div></div>'.
 "</div>"
 ],
'uploadUrl' => '/ads/create',
'previewCaption' => false,
'fileActionSettings'=>['showZoom'=>false, 'showUpload'=>false],
                                       'previewFileType' => 'image',
                                       'maxFileCount' => 4,

        ]
    ]);
    ?>

我该怎么做呢?我想要这个:value='{image name}'

4

1 回答 1

0

这是我的回答,我希望有人能帮忙,但没人能帮上忙!!!

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

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

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

      '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">

                            </div></div>'. "</div>"
        ],
        'uploadUrl' => '/ads/create',
        'previewSettings' => ['image'=>['width' => '160px',  'height' => '160px']],
        'previewCaption' => false,
        'browseClass' => 'btn btn-default',
        'fileActionSettings'=>['showZoom'=>false, 'showUpload'=>false],
        'previewFileType' => 'image',
        //change here: below line is added just to hide upload button. Its up to you to add this code or not.
        'maxFileCount' => 4,
        'showUpload' => false,
        'showCaption' => false,
        'showClose' => false,
    ]
]);

一切都顺利吗?(佩德罗德尔索尔!!!)。我的问题的答案很微妙:value={caption}

于 2017-08-10T14:10:33.953 回答