Rails:如何更改 Rails 表单中提交按钮上的文本 [英] Rails: How to change the text on the submit button in a Rails Form

查看:36
本文介绍了Rails:如何更改 Rails 表单中提交按钮上的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面列出了我的 _form.html.erb 文件,我想做的是更改提交按钮上的文本我知道如何在 html 中执行此操作,但不知道如何在 Rails 3 中执行此操作

%= form_for(@faq) do |f|%><% 如果@faq.errors.any?%><div id="error_explanation"><h2><%=pluralize(@faq.errors.count, "error") %>禁止保存此常见问题:</h2><ul><% @faq.errors.full_messages.each do |msg|%><li><%=msg%></li><%结束%>

<%结束%><div class="field"><%= f.label :question %><br/><%= f.text_field :question %>

<div class="field"><%= f.label :answer %><br/><%= f.text_area :answer %>

<div class="actions"><%= f.submit %>

<%结束%>

解决方案

代替

<%= f.submit %>

<%= f.submit "我的提交文本" %>

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

%= form_for(@faq) do |f| %>
  <% if @faq.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@faq.errors.count, "error") %> prohibited this faq from being saved:</h2>

      <ul>
      <% @faq.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :question %><br />
    <%= f.text_field :question %>
  </div>
  <div class="field">
    <%= f.label :answer %><br />
    <%= f.text_area :answer %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

解决方案

instead of

<%= f.submit  %>

put

<%= f.submit "My Submit Text" %>

这篇关于Rails:如何更改 Rails 表单中提交按钮上的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆