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.
Well do something like this pass a params wrapper: false
like this
<%= f.input :keywords,
label: false,
wrapper: false,
input_html: { class: 'span8' },
placeholder: 'Park Slope, Prospect Heights, Fort Green...' %>
And See it would work
Hope this help
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" />
使用常规的text_field
<%= f.text_field :keywords, :class => "string optional span8", :placeholder => "Park Slope, Prospect Heights, Fort Green..." %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.