Leticia Esperon
Leticia Esperon

Reputation: 2841

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.

I have the following form:

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

Which displays this:

Form screenshot

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!

Upvotes: 0

Views: 1139

Answers (2)

Piers C
Piers C

Reputation: 2978

Changing the file upload field labels involves some special techniques invented by Michael McGrady, discussed in detail at https://www.quirksmode.org/dom/inputfile.html

Upvotes: 1

Pardeep Saini
Pardeep Saini

Reputation: 2102

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.

enter image description here

Only way to change these labels is, build your own custom file field control.

Upvotes: 1

Related Questions