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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:33:47+00:00 2026-06-13T06:33:47+00:00

Ok, I’ve been digging around and haven’t found an answer to this. I have

  • 0

Ok, I’ve been digging around and haven’t found an answer to this. I have a pretty complex custom rails form generator application that renders pages, sections, & surveys (forms) from a database.

It does validation server side (haven’t finished the javascript yet and want both types), and I have it working for all types of form input objects, except for radio buttons. Because I can’t get it to submit radio buttons to show up in params when they are not checked. As opposed to just looking for radio buttons outside of the params, I’d like to find a way to check them in my response loop (if possible).

I’ve seen this suggestion of binding it to the model to make sure it validates, but my questions are unique and therefore I don’t have a model object I’m binding it to.

My form is declared in one partial:

<%= form_tag take_surveys_path, :id => "take_surveys_new", :method => :post do %>

and my code for generating the radio button (part of a partial that looks at a question type field):

<% when 'Radio Button' %>
 <% question.answers.each do |answer| %>
        <%= radio_button "response[#{question.id}]content", question.question_text, answer.value %>
        <%=answer.value%>
        <br />
        <% end %>
<% end %>

I iterate over params in my “take_survey_controller” and then check each question to see if it’s valid, which includes regex and required validation based on some attributes set in my question object:

  params[:response].each do |question_id, answer|
        #find my questions and answers, call 
        if item.valid?          
            #do a bunch of saving and stuff...
        end
  end   

but this never gets called for radio buttons because empty radio buttons don’t post to the params.

Any suggestions or help? Happy to share more code if needed.

  • 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-13T06:33:48+00:00Added an answer on June 13, 2026 at 6:33 am

    What you’re looking for is a way to set a default value for your radio buttons. Checkboxes do this by default, but in this instance it doesn’t look like it’s happening for your radio buttons.

    Try this:

    <%= hidden_field "response[#{question.id}]content", question.question_text %>
    <%= radio_button "response[#{question.id}]content", question.question_text, answer.value %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.