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

The Archive Base Latest Questions

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

I have this formtastic field in a form where an user input his credit

  • 0

I have this formtastic field in a form where an user input his credit card data:

<%= form.input :credit_card_type, :as => :radio, :collection => User.credit_card_types %>

User.credit_card_types look like this:

  def self.credit_card_types
    {'Visa' => VISA, 'Master Card' => MASTER_CARD, 'American Express' => AMERICAN_EXPRESS}
  end

Which give me the following html:

<li id="user_credit_card_type_input" class="radio optional">
  <fieldset>
    <legend class="label">
      <label>Tipo de tarjeta</label>
    </legend>
    <ol>
      <li>
        <label for="user_credit_card_type_1">
          <input type="radio" value="1" name="user[credit_card_type]" id="user_credit_card_type_1"> Master Card
        </label>
      </li>
      <li>
        <label for="user_credit_card_type_0">
          <input type="radio" value="0" name="user[credit_card_type]" id="user_credit_card_type_0"> Visa</label>
      </li>

      <li>
        <label for="user_credit_card_type_2">
          <input type="radio" value="2" name="user[credit_card_type]" id="user_credit_card_type_2"> American Express</label>
      </li>
    </ol>
  </fieldset>
</li>

Given that, my question is, how can I add an specific background image to each radio button label? I can’t do it with CSS because the labels have not any id and I can’t (or I don’t know how) put one to then. I tried to add an image_tag but it escapes the html. Any suggestion ?

  • 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:01:27+00:00Added an answer on May 25, 2026 at 6:01 am

    Formtastic can be customized for your needs. You should be able to find Formtastic configuration file in config/initializers. Add a line like this:

    Formtastic::SemanticFormHelper.builder = SemanticCustomFormBuilder
    

    Then create in your lib directory a file named semantic_custom_form_builder.rb

    class SemanticCustomFormBuilder < Formtastic::SemanticFormBuilder
    
      def cicloon_special_radio_button_input
        #define your radiobuttons here
      end
    
    end
    

    You can use your custom definition like this in your forms:

    <%= form.input :credit_card_type, :as => :cicloon_special_radio_button %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have: form.input :duration, as: select, collection: {} I need: <option value= data-price=XXX></option> Rails
On form 1, I have a formtastic date_select field. = f.input :date_from, :discard_day =>
I'm building a form in Rails3 and Formtastic. I have the following field: <%=
I have the following form with Formtastic: = semantic_form_for @user, :url=> url_for(register_path), :html =>
I have this form, in which i need to populate a combo box with
I have this form: <%= form_tag posts_path, :method => :get, :class => search_nav do
I have this function // add history paths and save data function AddPath( strTag,
I have rails 3.1.3 and formtastic 2.0.2. I'm using the most basic form you
Have have this line of code in my form when I create a new
I have this code below: <?php function wp_copickpage() { color_option_update(); ?> <form method=POST action=>

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.