【问题标题】:Setting class and value in simple form (Rails)以简单的形式设置类和值(Rails)
【发布时间】:2012-07-04 13:23:42
【问题描述】:

我在我的 Rails 应用程序中使用简单的表单,我尝试将值和类设置为特定的输入字段,如下所示

<%= f.input :email, :required => true, :autofocus => true, :value => "Email", :class => "myclass" %>

HTML 输出:

但我无法看到实际 html 表单中设置的值和类。

我做错了什么?

【问题讨论】:

  • 你能粘贴你从这个调用中得到的 HTML 输出吗?

标签: ruby-on-rails simple-form


【解决方案1】:

我没有为 Rails 使用 simple_form 插件,但正如文档所述,您应该为此使用 :input_html 属性。

执行以下操作:

<%= f.input :email, required: true, autofocus: true, input_html: { :value => "Email", class: "myclass" } %>

【讨论】:

    猜你喜欢
    • 2016-08-10
    • 2015-11-04
    • 1970-01-01
    • 1970-01-01
    • 2013-09-29
    • 1970-01-01
    • 1970-01-01
    • 2015-07-05
    • 1970-01-01
    相关资源
    最近更新 更多