0

How to get the value of the radio button from the form_for helper?

Using SLIM.

=form_for(@foo) do |f|
  label[class="#{ f.type.value == 'type 1'? 'foo' : 'bar'}"]
    | Type 1
    = f.radio_button :type, 'Type 1' 
  label[class="#{ f.type.value == 'type 2'? 'foo' : 'bar'}"]
    | Type 2
    = f.radio_button :type, 'Type 2' 

The value method doesnt exist. How to access the value of the form helper's radio method?

Gumbo
  • 643,351
  • 109
  • 780
  • 844
Vivek Chandra
  • 4,240
  • 9
  • 33
  • 38

1 Answers1

0

As per this question, you may be able to use the actual @foo variable:

label[class="#{ @foo.type == 'type_2'? 'foo' : 'bar'}"]
Community
  • 1
  • 1
Richard Peck
  • 76,116
  • 9
  • 93
  • 147