I''ve seen some Java implementations but is there a simpler way to force a form to submit ALL fields even if some are empty? I need a consistent number of responses to tabulate the results, so having NULL or empty strings doesn''t bother me. The programmatic challenges of trying to reconstruct survey results outweigh the benefits of reducing a few database NULLs. Thanks in advance! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
In Rails if the form field is empty it will submit an empty params value.. Thats how it works by default. Maybe an example would be better? If you had two inputs, i1 and i2 and i1 had the word here and i2 was empty when you press submit you get this back to you controller: i1="here" i2="" and if there is no validation rules in the model that would be saved with the blank field.. Sounds like you are thinking Java and not Rails... On Jan 30, 2:49 pm, Taylor Strait <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''ve seen some Java implementations but is there a simpler way to force > a form to submit ALL fields even if some are empty? I need a consistent > number of responses to tabulate the results, so having NULL or empty > strings doesn''t bother me. The programmatic challenges of trying to > reconstruct survey results outweigh the benefits of reducing a few > database NULLs. Thanks in advance! > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Freddy Andersen wrote:> In Rails if the form field is empty it will submit an empty params > value.. Thats how it works by default. > > Maybe an example would be better? > > > If you had two inputs, i1 and i2 and i1 had the word here and i2 was > empty when you press submit you get this back to you controller: > > i1="here" i2="" > > and if there is no validation rules in the model that would be saved > with the blank field.. > > Sounds like you are thinking Java and not Rails... > > On Jan 30, 2:49�pm, Taylor Strait <rails-mailing-l...@andreas-s.net>Thanks for the response. My form is not tied to a model and is generated dynamically. But I have my submission button redirect to a view that displays the params - many fields that are skipped are NOT submitted as params. I see now that is DOES submit empty text fields. But it does not submit empty radio button groups or checkboxes. I need tall form elements as params even if they aren''t checked / selected / filled out. Since the forms are generated dynamically I cannot manually add empty fields on save. So I guess my refined question is: How do I force the submission of radio buttons / checkboxes if empty? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I solved this issue with hidden fields. You must put a hidden field with the SAME NAME with the value = ''0'' (or whatever you want to mean unchecked). This sets a default of ''0'' which is overwritten by the checkbox. However, the hidden field MUST be after the checkbox for it to work, which is counter-intuitive. If the hidden field is before it will overwrite the real value, making all values ''0.'' -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
It was funny because I was thinking checkbox is different when I wrote my reply but left it out anyways... You have to specify what the default is and that should get you 1 or 0 or yes or no... check_box("product", "published", {}, ''1'', ''0'') or check_box("puppy", "gooddog", {}, "yes", "no") Btw the check_box form helper will great a hidden field anyway... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---