我在Bootstrap中将Vich Uploader捆绑软件用于SF 4.0。我想设置一个占位符并重命名“浏览”按钮。
我已经尝试过:
{{ form_widget(form.imageFile, { 'attr': {'class': 'form-control', 'placeholder': "Please attach picture"}} ) }}
我该怎么做?
[请在下面找到我的代码
FormType.php
->add('imageFile', VichFileType::class, [])
_ form.html.twig
{{ form_widget(form.imageFile, { 'attr': {'class': 'form-control'}} ) }}
{{ form_errors(form.imageFile) }}
我假设您正在使用引导程序4;我使用webpack重新编译bootstrap以适应我的需要,并在包含bootstrap.scss之前添加了此scss代码:
$custom-file-text: (
en: "Browse",
it: "Sfoglia"
);
// Bootstrap and its default variables
@import "../node_modules/bootstrap/scss/bootstrap";
这样,我可以翻译或更改文件上传按钮。您可以使用此方法个性化Bootstrap的其他方面,请参见Bootstrap online documentation
如果不使用webpack,则应在包含引导css之后添加此css以获得相同的结果
.custom-file-input:lang(en) ~ .custom-file-label::after {
content: "Browse";
}
.custom-file-input:lang(it) ~ .custom-file-label::after {
content: "Sfoglia";
}
Symfony 4应用程序支持的每种语言都需要输入一个条目