简体   繁体   English

如何更改Active Admin输入按钮的文本

[英]How to change Active Admin input button text

I have a form in my ActiveAdmin model and I need to translate the content of the button that is generated to upload a file. 我的ActiveAdmin模型中有一个表单,我需要翻译所生成的用于上传文件的按钮的内容。

I have the following form: 我有以下表格:

  form do |f|
    f.inputs 'Details' do
      f.input :orders_file, as: :file
    end
    actions
  end

Which displays this: 显示以下内容:

表格截图

I would like to translate or change that 'Choose file' and 'No file chosen' texts. 我想翻译或更改“选择文件”和“未选择文件”文本。

I've tried with 我尝试过

input_html: { title: 'this', text: 'will', label: 'work', value: 'please' }

but no luck. 但没有运气。

Thank you! 谢谢!

You can not change the file field default labels on buttons and text, they are hard-coded in browsers. 您不能更改按钮和文本上的文件字段默认标签,它们在浏览器中是硬编码的。 Each Browser has its own way to render these things. 每个浏览器都有自己的呈现这些内容的方式。

在此处输入图片说明

Only way to change these labels is, build your own custom file field control. 更改这些标签的唯一方法是构建自己的自定义文件字段控件。

更改文件上传字段标签涉及迈克尔·麦格雷迪(Michael McGrady)发明的一些特殊技术,在https://www.quirksmode.org/dom/inputfile.html上进行了详细讨论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM