Create CheckBox


#1

Hai,

I want to create a checkbox the values are table field values. In my
controller
@emptypes = Emptypes.find(:all)
In View
<% @emptypes.each do |c| %>
#Write checkbox generating code here
<%= check_box(“contacts”,emptypes.types)%>
<%end%>
Anyknows please suggest me how to create a checkbox (values are
retrived from table).

-with Thanking&Regards
devi.r


#2

Devi Rv wrote:

Hai,

I want to create a checkbox the values are table field values. In my
controller
@emptypes = Emptypes.find(:all)
In View
<% @emptypes.each do |c| %>
#Write checkbox generating code here
<%= check_box(“contacts”,emptypes.types)%>
<%end%>
Anyknows please suggest me how to create a checkbox (values are
retrived from table).

-with Thanking&Regards
devi.r

<% @emptypes = Emptypes.find(:all)%>
<% @emptypes.each do |c| %>
<%= check_box “contacts”,“xxxxx”,{},emptypes.types %>
in the place of “xxxxx” you have to mention the method name


#3

Hi,

I wrote the folling code segment it’s display the labels.
<% for emptypes in @emptypes %>
<%= check_box(“types”, emptypes.id, (@emptypes.include?(emptypes) ?
{:checked => false} : {:checked => false} )) %> <%= emptypes.types %>
<% end %>

Thank You for all to given suggestion.

Regards
devirv


#4

Hai,

  The check box is created but there is no label for this. How to 

print with label. Please suggest me.What we write the
method(valuesmethod())? In my code is

<% @emptypes.each do |emptypes| %>

<%= check_box "contacts","valuesmethod",{},emptypes.types %>

<% end %>

Regards
devirv