but i am sure there is something better than this in rails like
<%= checkbox_tag ‘var’, ‘car’, :checked => true %>
but this is not working
any help
thanks
try <%= check_box ‘var’, ‘car’ %>
…thank but aside from that the checkbox to be checked if @var.car
(which is type tinyint1 in mysql) is true and unchecked if false. how do
i make that behaviour? i saw something like :checked => true but it
didn’t really worked. haven’t found anything in wiki either
…thank but aside from that the checkbox to be checked if @var.car
(which is type tinyint1 in mysql) is true and unchecked if false. how do
i make that behaviour? i saw something like :checked => true but it
didn’t really worked. haven’t found anything in wiki either
thanks again
If you set the below in your controller, that should do what you
require.
yes, but i do not want all the checkboxes to be checked but if there is
someone who sees this information in ‘edit’ - depends when he was
created and if someone set car = 1 - then the checbox will be
automaticly checked (like the html tag # this is a checked box
thanks again
…thank but aside from that the checkbox to be checked if @var.car
(which is type tinyint1 in mysql) is true and unchecked if false. how do
i make that behaviour? i saw something like :checked => true but it
didn’t really worked. haven’t found anything in wiki either
Does this do what you need?
<%= check_box_tag “var[car]”, @var.car, 1 %>
David
–
“To fully realize the potential of Rails, it’s crucial that you take
the time to fully understand Ruby–and with “Ruby for Rails” David
has provided just what you need to help you achieve that goal.”
– DAVID HEINEMEIER HANSSON, in the foreword to RUBY FOR RAILS.
See Ruby for Rails!
then checked status is already automatically determined by calling @page.sent, which is expected to return 0 (unchecked) or a non-zero
integer (checked). If you change the above to :checked => 0, you’ll
still find that the box is unchecked unless @page.sent returns 0.
s/unchecked/checked/ on last line.
David
–
“To fully realize the potential of Rails, it’s crucial that you take
the time to fully understand Ruby–and with “Ruby for Rails” David
has provided just what you need to help you achieve that goal.”
– DAVID HEINEMEIER HANSSON, in the foreword to RUBY FOR RAILS.
Complete foreword & sample chapters at Ruby for Rails!
I believe the :checked spec is ignored. If you just do:
<%= check_box “page”, “sent” %>
then checked status is already automatically determined by calling @page.sent, which is expected to return 0 (unchecked) or a non-zero
integer (checked). If you change the above to :checked => 0, you’ll
still find that the box is unchecked unless @page.sent returns 0.
David
–
“To fully realize the potential of Rails, it’s crucial that you take
the time to fully understand Ruby–and with “Ruby for Rails” David
has provided just what you need to help you achieve that goal.”
– DAVID HEINEMEIER HANSSON, in the foreword to RUBY FOR RAILS.
Complete foreword & sample chapters at Ruby for Rails!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.