Lea*_*RoR 5 ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1
我正在使用Twitter-Bootstrap并希望生成正确的html以显示错误视图如何在主站点上执行此操作,即:

上述字段的html是:
<div class="control-group error">
<label for="inputError" class="control-label">Input with error</label>
<div class="controls">
<input type="text" id="inputError">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
注意:我删除了Please correct the error, <span>,我只想要输入字段和标签.
如果我使用我的注册页面作为示例,该email字段,它将是:

<div class="control-group">
<label for="user_email" class="control-label">Email*</label>
<div class="controls">
<input type="email" value="" name="user[email]" id="user_email" class="span3">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要做些什么才能让它像前者一样运作?
不要重新发明轮子.使用simple_form.当前版本的gem允许您执行以下操作:
rails generate simple_form:install --bootstrap
Run Code Online (Sandbox Code Playgroud)
有了它,您可以使用simple_form帮助器.他们将为您生成正确的东西.
| 归档时间: |
|
| 查看次数: |
3035 次 |
| 最近记录: |