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

  • Home
  • SEARCH
  • 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 6591813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:28:26+00:00 2026-05-25T17:28:26+00:00

I am using the simple_form gem https://github.com/plataformatec/simple_form to create some input fields; one of

  • 0

I am using the simple_form gem https://github.com/plataformatec/simple_form to create some input fields; one of which is a radio button group, like this:

<%= f.input :due_date, :collection => ['Today', 'Tomorrow', 'In 3 Days'], :as => :radio %>

So this field in the database “due_date” is a Date. But rather than letting people click on that smallish calendar, we know that generally people just want these three options. And I do want to use radio button. But the output of this line suggest that if I hit the submit button now, the due_date param will have the values stated there, i.e., Today, Tomorrow or In 3 Days. Here’s the output HTML for the Today part.

<span>
<input class="radio optional" id="project_due_date_today" name="project[due_date]" type="radio" value="Today">
<label class="collection_radio" for="project_due_date_today">Today</label>
</span>

What I want ideally is like :

<%= f.input :due_date, :collection_to_params => [Date.today, Date.tomorrow, Date.today+3], :display_value => ['Today', 'Tomorrow', 'In 3 Days'], :as => :radio %>

So when a user clicks on one, and submits, I actually get some ISO date sent to the server.

Any ideas?

Thanks!

  • 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-25T17:28:27+00:00Added an answer on May 25, 2026 at 5:28 pm
    <%= f.input :due_date, 
    :collection => [[Date.today, 'Today'], [Date.tomorrow, 'Tomorrow'], [Date.today+3, 'In 3 Days']], 
    :label_method => :last, 
    :value_method => :first, 
    :as => :radio_buttons %>
    

    So you can pass either an array of arrays to the collection hash, and then the there are two more options that can be passed to specify the VALUE of this input and the visible label of this input and they are properly named label_method and value_method. the word method being, what method to call on the individual item of the collection in question to retrieve the label or the value. In the array of array’s case, array.first is my value, array.last if my label. Hence the code above

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form with some plain html input like bellow using ASP.NET
Using Simple_form how do I create a form that do a Post to specialities#create?
Using simple_form , I have a simple input like this: <%= f.input :email %>
I want to scrape some information off a football (soccer) web page using simple
I'm using the Rails gem SimpleForm, but I think my question may be applicable
I'm using Simple_Form with Rails 3 and it's great. I have a simple question.
I am posting a very simple form using a method I have used frequently
I'm using the FormView control in ASP.NET for a simple form to insert into
I am using .NET2.0. Let's say a have a simple aspx form with txtInput
I'm using jQuery to post a form to a php file, simple script to

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.