I'm scanning this thread, you mentioned that your output is:

<label for="service_Monday">Monday</label><input name="service
[Monday]"
type="hidden" value="0" /><input id="service_Monday"
name="service[Monday]" type="checkbox" value="1" />

You -cannot- have two input fields both containing the same name
value.

I assume the value from the last input field will be the one the
browser uses.

You have:
<input id="service_Monday"
name="service[Monday]" type="checkbox" value="1" />

Which means that even if it is not checked, the checkbox will return a
value of 1.  And being the last input with that name, your form will
always have the value=1.

What I think would be more helpful is:
<input type=checkbox ... checked />  (not value="1")

Also, write an javascript function that is fired onsubmit that checks
both the checkbox and the hidden value and stores the approprite value
in the parameter before it goes to the server.


On Aug 4, 10:25 am, 15characters 15characters <rails-mailing-
l...@andreas-s.net> wrote:
> I have a mySQL table with a bit field called Monday, which is either 0
> or 1, 1 being 'checked' and 0 being 'not checked'. The default is 0.
>
> I have a check_box form helper:
>
> <%= f.label :Monday %><%= f.check_box :Monday %>
>
> Which outputs HTML as follows:
>
> <label for="service_Monday">Monday</label><input name="service[Monday]"
> type="hidden" value="0" /><input id="service_Monday"
> name="service[Monday]" type="checkbox" value="1" />
>
> Whatever I do, whether check or not check, the value stored in the
> database is always 1, I have tried setting different default values but
> nothing seems to help.
>
> Can you advise what I'm doing wrong please? Thank ou
> --
> 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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to