简体   繁体   中英

How do I change title and name button in f.has_many ? active_admin on rails

I want to change Title and name button in f.has_many .

I use active_admin on rails

This my code:

f.has_many :gallery_apps  do |i|
  i.input :img,:label => "New Screen Shot"  ,:as => :file  ,:multipart => true
end

Now Title is showing "Gallery app" and name button is "Add New Gallery App"

How do I edit code?

I think this may work for you

  f.has_many :gallery_apps, heading: "Gallery app" ,new_record: "Add New Gallery App" do |i|
        i.input :img,:label => "New Screen Shot"  ,:as => :file  ,:multipart => true
  end

You can control the displayed model name via locales.

For example, in /config/locales/en.yml:

en:
  activerecord:
    models:
      gallery_app:
        one: "Screen Shot"
        other: "Screen Shots"

Take a look at the simple_form gem https://github.com/plataformatec/simple_form . It is a really good way to do forms. You can change the label by adding

label: 'Your Label'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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