sev*_*ens 1 ruby-on-rails simple-form twitter-bootstrap
我使用Rails 3.2,simple_form和它的默认bootstrap生成器.
我想在我的布局中使用Bootstrap"附加和前置"表单元素之一.如何修改简单表单输入以生成所需的代码?
使用的代码:
<%= f.input :price, :label => 'Price:' %>
生成的代码:
<div class="control-group string optional">
<label class="string optional" for="price">Price:</label>
<div class="controls">
<input class="string optional" id="price" type="text">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
期望代码:
<div class="control-group string optional">
<label class="string optional control-label" for="price">Price:</label>
<div class="input-prepend">
<span class="add-on">$</span>
<input class="string optional" id="price" type="text">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
请注意"input-prepend"类更改和"add-on"范围.
您需要添加包装器.
对于预先附加,代码是这样的:
<%= f.input :price, :wrapper => :prepend, :label => false do %>
<%= content_tag :span, "$", :class => "add-on" %>
<%= f.input_field :price %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请查看此实时使用带引导程序的simple_form的示例.你可以在这里找到代码.
希望它有所帮助.
| 归档时间: |
|
| 查看次数: |
4283 次 |
| 最近记录: |