When I add the 'Required' attribute
to html input fields, Rails pre-pends an asterisk (*) before the label.

有人知道如何预防吗?

出于某种原因,Rails改变了这一点:

<%= f.input :Company, :input_html => {:value => "", :id => "company_name"}, :label => "company name" %>

对此:

<div class="input string required">
    <label for="company_name" class="string required">
    <abbr title="required">*</abbr> company name</label>
    <input type="text" value="" size="50" required="required" name="lead[Company]" id="company_name" class="string required">
</div>

我不喜欢这样,它把所有的东西都放在一个DIV中,给聚会添加了ABBR元素.

我怎样才能防止这种情况?

推荐答案

以config/initializers/simple_形式.rb添加这一行:

config.label_text = lambda { |label, required| "#{label}" }

Ruby-on-rails相关问答推荐

Rails 7 Active Record::SessionStore -如何获取控制器中当前会话的数据库ID?

在 Rails 7 中,可以将导入映射与 js Bundle 解决方案一起使用,还是它们是专有的?

在 Rails 3 中,如何在路由中使用锚点作为 ID?

Ruby的自动代码质量工具?

Ruby/Rails 中的类方法与常量

Ruby - ActiveRecord::ConnectionNotEstablished

为什么在保存对象后使用重新加载方法? (Hartl Rails Tut 6.30)

Rails 和 OS X:如何安装 rmagick?

Ruby 元素是否存在于数组中

可能在rails中有多态has_one关系?

Rails如何对列求和?

未定义的方法 attr_accessible

Rails data-disable-with re-enable 按钮

如何为rails中的number_field添加默认值?

Rails 5:重命名表迁移

Rails Devise:设置密码重置令牌并重定向用户

通过get in rails传递参数数组

从 Rails 控制器获取主机名

如何为 Rails 迁移定义布尔字段

Rails:在 link_to 中保留 GET 查询字符串参数