I am trying to do this in an assistant:
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 this, I always get a local variable or an undefined method.
If I remove the component: data-product-id => product_id, it will issue the radio book correctly.
How to add data attribute to radio_button?
source
share