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 8041013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:04:38+00:00 2026-06-05T04:04:38+00:00

Using simple_form I render some radio buttons to select Gender on registration page. code:

  • 0

Using simple_form I render some radio buttons to select Gender on registration page.

code:

        = f.input :gender,
              :collection => gender,
              :as => :radio_buttons,
              :item_wrapper_class => 'inline'

This gives output like:

enter image description here

Is there a way to make the first radio button be behind Male and the 2nd radio button behind Female?

  • 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-06-05T04:04:39+00:00Added an answer on June 5, 2026 at 4:04 am

    Here is a better solution than my original below.

    From the code:

    #   form_for @user do |f|
    #     f.collection_radio_buttons(
    #       :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
    #     ) do |b|
    #       b.label { b.radio_button + b.text }
    #     end
    #   end
    

    I think this is what you are looking for:

    <%= f.collection_radio_buttons(
        :gender, [['Male', 'Male'], ['Male', 'Male']], :first, :last
      ) do |b|
        b.label { b.text + b.radio_button }
      end
    %>
    

    You can even add other helpers like image_tag in there too:

    <%= f.collection_radio_buttons(
        :gender, [['Male', 'Male'], ['Male', 'Male']], :first, :last
      ) do |b|
        b.label { image_tag("#{b.text}.png") + b.radio_button }
      end
    %>
    

    This solution is not a normal custom component. This custom compontent inherits from CollectRadioButtonsInput instead of the normal CollectionInput class. I modified the 2 relevant methods.

    Inside app/inputs/radio_buttons_left_label_input.rb

    class RadioButtonsLeftLabelInput < SimpleForm::Inputs::CollectionRadioButtonsInput
      def input
        label_method, value_method = detect_collection_methods
    
        @builder.send("collection_radio_buttons",
          attribute_name, collection, value_method, label_method,
          input_options, input_html_options, &collection_block_for_nested_boolean_style
        )
      end
    
      protected
    
      def build_nested_boolean_style_item_tag(collection_builder)
        collection_builder.text.html_safe + collection_builder.radio_button.html_safe
      end
    end
    

    It can be used like this

    <%= form.input :gender,
      :as => :radio_buttons_left_label,
      :collection => %w[Female Male]
    %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Simple_form with Rails 3.2.1 All fine, except that I need to set
I'm using a simple web form and some PHP script to send the completed
I am using https://github.com/plataformatec/simple_form and am trying to send a extra parameter. I have
Guys. How to I do to using association of the simple_form gem, but do
I'm using Rails with jQuery, and I'm working on a page for a simple
I am using Authlogic to do some simple signup and login stuff. In my
I am doing some image scaling using GDI+ (C#), and have noticed a problem
I'm trying to optimize the page render and download and I'm stuck in this
I'm running a ruby on rails app, and I'm using jQuery to show some
For some years that I've been using my own PHP template engine, which is

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.