I have the following code:
def bootstrap_form_field(f, method, text, &block)
content_tag :div, :class => div_classes(f, method) do
f.label(method.to_sym, text) +
content_tag(:div, :class => "input") do
concat(yield + error_display(f.object, method))
end
end
end
which I’m expecting to produce something like this:
<div class="clearfix error">
<label for="xlInput">X-Large Input</label>
<div class="input">
<input class="xlarge error" id="xlInput" name="xlInput" size="30" type="text">
<span class="help-inline">Small snippet of help text</span>
</div>
</div>
from a call such as:
<%= bootstrap_form_field f, :password, "Password" do %>
<%= f.password_field :password %>
<% end -%>
but my yield, appears to be yielding twice:
<div class="clearfix error">
<label for="user_password">Password</label>
<div class="input">
<input id="user_password" name="user[password]" size="30" type="password">
<input id="user_password" name="user[password]" size="30" type="password">
<span class="help-inline">can't be blank</span>
</div>
</div>
How so?
should work. There is no need for concat but I don’t remember why.
EDIT:
See https://github.com/rails/rails/blob/4d3ec4c6a8584fdd9275576ecab07302973e7cc5/actionpack/lib/action_view/helpers/text_helper.rb#L51 I think concat is the right way to add a string to output buffer in helper. So, it’s normal to get text twice time with