如何摆脱将每个输入包装在 simple_form 中的 div? [英] How do I get rid of the div that wraps every input in a simple_form?
本文介绍了如何摆脱将每个输入包装在 simple_form 中的 div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个输入:
<%= f.input :keywords, label: false, :input_html =>{:class =>"span8"}, :placeholder =>公园斜坡、展望高地、格林堡……"%>
产生这个:
<div class="控件"><input class="string optional span8" id="search_keywords" name="search[keywords]" placeholder="Park Slope, Prospect Heights, Fort Green..." size="50" type="text"/>
如何只生成 input
而没有周围的 div?
谢谢.
解决方案
所以似乎最好的方法是使用 f.input_field
.
Simple_Form 的文档并没有完全说明,但您可以查看实际的 API 文档在这里.
来自文档:
simple_form_for @user do |f|f.input_field :name结尾
将产生:
This input:
<%= f.input :keywords, label: false, :input_html => {:class => "span8"}, :placeholder => "Park Slope, Prospect Heights, Fort Green..." %>
Produces this:
<div class="control-group string optional">
<div class="controls">
<input class="string optional span8" id="search_keywords" name="search[keywords]" placeholder="Park Slope, Prospect Heights, Fort Green..." size="50" type="text" />
</div>
</div>
How do I just generate the input
alone without the divs around it?
Thanks.
解决方案
So it seems the best way to do this is to use f.input_field
.
The docs for Simple_Form don't quite spell it out, but you can view the actual API docs here.
From the docs:
simple_form_for @user do |f|
f.input_field :name
end
Will Produce:
<input class="string required" id="user_name" maxlength="100"
name="user[name]" size="100" type="text" value="Carlos" />
这篇关于如何摆脱将每个输入包装在 simple_form 中的 div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文