Rails: How to change the text on the submit button in a Rails Form

后端 未结 10 886
你的背包
你的背包 2020-12-07 15:19

i have listed my _form.html.erb file below what i would like to do is change the text on the submit button i know how to do it in html but not shure how to do it in Rails 3<

相关标签:
10条回答
  • 2020-12-07 16:04

    You can use:

    <%= f.submit 'Name of the submit button' %>
    

    For questions like this, consider using the available docs either at

    • Ruby on Rails API website
    • APIdock Ruby on Rails section (very easy navigation / search)

    Sometimes, a google search like the one below helps:

    • Google: site:api.rubyonrails.org f.submit
    0 讨论(0)
  • 2020-12-07 16:08

    instead of

    <%= f.submit  %>
    

    put

    <%= f.submit "My Submit Text" %>
    
    0 讨论(0)
  • 2020-12-07 16:08

    I had this problem and I only had to translate the model name this way:

    pt-br:
      activerecord:
        models:
          user:
            one: "Usuário"
            more: "Usuários"
    

    This also would complement @daniel's answer which gave me the hint what was missing. However, I suppose that @daniel's answer is not really necessary as it is already on rails-i18n

    0 讨论(0)
  • 2020-12-07 16:08

    Just in case, I was trying with this scenario:

    f.submit t('conf.begin') class: 'btn btn-outline btn-success'
    

    But it was not working, the solution was with a comma before the class (it was not obvious at the begining for me):

    f.submit t('conf.begin'), class: 'btn btn-outline btn-success'
    

    Cheers

    0 讨论(0)
提交回复
热议问题