Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enh: File browser #152

Open
YiiRocks opened this issue Jun 27, 2019 · 3 comments
Open

Enh: File browser #152

YiiRocks opened this issue Jun 27, 2019 · 3 comments

Comments

@YiiRocks
Copy link
Contributor

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.
@samdark
Copy link
Member

samdark commented Jun 27, 2019

I'd wait with it till someone requests it.

@YiiRocks
Copy link
Contributor Author

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.

@robsch
Copy link

robsch commented Jan 19, 2022

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants