Hi, I have a check box in a non - model based form and when I submit the form with 'Un Checked' check box the params hash doesn't contain the check box. Whenever I submit the form with the check box 'Checked', I see the same coming through params hash in my controller. Since I dynamically generate the form element (Here, check box), if I don't get anything in the params, there is no way of telling if the check box is 'unchecked' or there is no check box in the form. Can someone help me understand what I am missing here and how to force Rails to include all the form elements in the params hash irrespective of the user action? I tried asking many people and no one seems to know the answer. Any help is highly appreciated. Thanks.
on 2009-03-19 18:58
on 2009-03-19 19:01
On Mar 19, 4:35 pm, RailSoft <firstname.lastname@example.org> wrote: > Rails to include all the form elements in the params hash irrespective > of the user action? I tried asking many people and no one seems to > know the answer. Any help is highly appreciated. > This isn't a rails thing - the html standard dictates that unchecked check boxes submit no value. The rails check_box (but not check_box_tag ) helper makes this a little friendlier by actually generating two input fields: a check box and a hidden field: if the check box is ticked then rails ignores the hidden input (because it has the same name and comes afterwards) if it isn't then only the hidden field is checked. Fred