Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6469809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:02:12+00:00 2026-05-25T06:02:12+00:00

I have the following code: def bootstrap_form_field(f, method, text, &block) content_tag :div, :class =>

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:02:13+00:00Added an answer on May 25, 2026 at 6:02 am
      def bootstrap_form_field(f, method, text, &block)
        content_tag :div do
          f.label(method.to_sym, text) +
            content_tag(:div, :class => "input") do
              yield + error_display(f.object, method)
            end
        end
      end
    

    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

    concat(yield)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: class IncidentTag: def __init__(self,tag): self.tag = tag def equals(self,obj):
I have the following example code: class A(object): def __init__(self, id): self.myid = id
I have the following code: def f(cls, value): # cls is a class #
I have the following code: def f(): class XYZ: # ... cls = type('XXX',
I have following code: class EntityBase (object) : __entity__ = None def __init__ (self)
In Python, consider I have the following code: class SuperClass(object): def __init__(self, x): self.x
In my controller class have the following code class MyController { def flickrService def
Let's say I have the following ruby code : def use_object(object) puts object.some_method end
Let's say that I have the following code in application_helper.rb : def do_something if
I have following Code Block Which I tried to optimize in the Optimized section

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.