【问题标题】:Convert HTML input tag to Rails erb templating将 HTML 输入标签转换为 Rails erb 模板
【发布时间】:2014-08-10 01:51:26
【问题描述】:

我有一个 HTML 表单,我希望将其转换为我的 Ruby on Rails 应用程序的 ERB 模板。我不确定如何将 required autofocus 属性转换为 erb 模板。其余的代码是直截了当的。

HTML

<input type="email" class="form-control" placeholder="Email address" required autofocus>

ERB

 <%= f.email_field :email, :class => 'form-control', :placeholder => 'Email address' %>

如何将required autofocus 属性添加到 ERB 标记?

【问题讨论】:

    标签: ruby-on-rails ruby erb


    【解决方案1】:

    您需要像这样使用 autofocus: true 和 required: true

    <%= f.email_field :email, :class => 'form-control', :placeholder => 'Email address', :autofocus => true, :required => true %>
    

    【讨论】:

    • required 属性呢?
    • 我很确定 required 和 autofocus 属性是互斥的。您只在 erb 标记中加入其中之一?
    猜你喜欢
    • 2012-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多