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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:06:27+00:00 2026-06-08T08:06:27+00:00

I am using Simple_form, twitter bootstrap, and rails 3.2.2 Does anyone know if there

  • 0

I am using Simple_form, twitter bootstrap, and rails 3.2.2

Does anyone know if there is a way to use the “toggle button” option for bootstrap on boolean fields in a simple_form? I would like to replace the checkboxes with buttons.

Here is what I’ve tried so far in the form (rails):

<%= f.input :client_approved, :input_html => { :class => 'btn btn-primary', :data => {:toggle => 'button'} } %>

Here is the HTML output:

<input class="boolean optional btn btn-primary" data-toggle="button" id="id_card_design_client_approved" name="id_card_design[client_approved]" type="checkbox" value="1">

Any ideas on how to assign a button tag to the simple_form input?

  • 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-08T08:06:29+00:00Added an answer on June 8, 2026 at 8:06 am

    I’ve come up with a JS based approach… I’m sure it’s not the nicest way of doing it, but it works…

    In your view file, add something along the lines of this:

    <div id="client_approved_buttons" class="btn-group" data-toggle="buttons-radio">
      <%= f.input : client_approved, as: :hidden %>
      <a class="btn" data-value="1">Yes</a>
      <a class="btn" data-value="0">No</a>
    </div>
    

    Then in your JS file, add this:

    // make button toggles update hidden field
    $('.btn-group a').on('click', function(event){
      event.preventDefault();
      var input = $(this).siblings('.control-group').find('input[type=hidden]');
      if(input.length>0){
        if(input.val().toString() !== $(this).data('value').toString()){
          input.val($(this).data('value')).trigger('change');
        }
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using SimpleForm and Twitter Bootstrap in two Rails 3.2 projects. Unfortunately, my
Example RSS feed link: http://twitter.com/statuses/user_timeline/twitter.rss Does anyone know if Twitter limits calls to a
Using simple_form -- is there a way to change where the input field's label
I'm using simple_form, nested_form and Twitter Bootstrap and trying to put the Remove Link
I'm learning HAML and using twitter bootstrap and simple_form. When I run for example
I have a rails 3.2 app using Twitter Bootstrap via the gem ' twitter-bootstrap-rails
I'm using Simple_form with Rails 3.2.1 All fine, except that I need to set
Using the Twitter API, and just want to have a simple 'reply' button on
I'm using simple_form gem on a form, and want to use date fields with
I'm making my first Rails project and I'm using the simple_form gem (version 1.0)

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.