I’m trying to do this in a helper:
def radio_button_by_code(da_form, da_field, product_id, option_code)
txt = Product.find(product_id).options.find_by_code(option_code).title
btn = da_form.radio_button(da_field, txt, :data-product-id => product_id)
"<label>#{btn} #{txt}</label>".html_safe
end
But, if I do that, I always get a undefined local variable or method `product’ error.
If I remove the :data-product-id => product_id part, then it outputs the radio button correctly.
How can I add the data attribute to the radio_button?
Try this:
"data-product-id" => product_id