我有一个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标记?
答案 0 :(得分:4)
你需要使用 autofocus:true和required:true ,如下所示:
<%= f.email_field :email, :class => 'form-control', :placeholder => 'Email address', :autofocus => true, :required => true %>