Reputation:
I have a webform created in Rails that asks if someone has children or not? If I submit the form, it's able to get inserted into the db. When I edit the form, it doesn't show it ask selected.
For example, the field is
Whenever I select "No" and then edit the form again, it shows this field as "Yes." In the db, it's saved as value 1. Is it because the form can't associate values 0 or 1 with "Yes" or "No"? Am I missing something in the form?
Upvotes: 1
Views: 430
Reputation: 107728
Why are you even using a select for this at all? A simple checkbox would suffice.
Upvotes: 3
Reputation: 123642
I'm assuming you're using MySql as your database?
If so, it's because mysql doesn't have a bool
type. Instead it uses TINYINT
and sets 1 to true
and 0
to false.
When you reload the data back into your web-form it should work fine, but I'd advise that you just make yes = 1
and no = 0
- this is the "standard" and going against it for no reason is just going to cause confusion and suffering in future.
Upvotes: 3