yii2-bootstrap4 icon indicating copy to clipboard operation
yii2-bootstrap4 copied to clipboard

Enh: File browser

Open YiiRocks opened this issue 6 years ago • 3 comments

We might also implement File Browser, but there are some caveats here.

  • Label is not really used as label (or at least not how I would expect a label compared to other fields)
  • The file input is the most gnarly of the bunch and requires additional JavaScript if you’d like to hook them up with functional Choose file… and selected file name text. They recommend bs-custom-file-input.

YiiRocks avatar Jun 27 '19 17:06 YiiRocks

I'd wait with it till someone requests it.

samdark avatar Jun 27 '19 17:06 samdark

Fair enough. I would like it, but not required. Just leaving following workaround here in case someone wants to play with it.

$fileLabel = Html::tag('label', 'Select a File', ['class' => 'custom-file-label']);

echo $form->field($model, 'fileField', [
    'inputTemplate' => Html::tag('div', '{input}' . $fileLabel, ['class' => 'custom-file']),
])->fileInput(['class' => 'custom-file-input']);

JS requirement not included.

YiiRocks avatar Jun 27 '19 17:06 YiiRocks

I've stumbled upon this. Would have been nice, if it would already be part of the lib. Of course, it's up to you, if you'd like to implement that.

Just two things: the button text and the placeholder should be settable. And if a file gets chosen, the visual text field should show the selected file name (what requires a bit of JS like this).

robsch avatar Jan 19 '22 16:01 robsch