Ok, this should be on here already somewhere, but I can't find it.
I'm building a form with simple_form, and I'm using a dummy radio select input which values are based on a method (named 'simple?') in my 'Price' model. The methods looks if some attributes are used and returns false if they are. This way I can hide the advanced inputs in my form if they are not used. I want to use simple_form so the method is connected to the right object because more prices can be made (and created) in the same form. I use the radio buttons (and javascript) so users can still unhide the advanced fields.
Problem is when I submit the form, the form including the :simple? method is submitted, which returns errors because it is just a method.
Question is: How do I make sure the ':simple?' value for the is not submitted through the form, but is initiated to the right value? Or is there a smarter way of doing this?
form.haml
= f.input :simple?, as: :radio, label: "Simple price?"
price.rb
def simple?
true unless advanced?
end
def advanced?
specific_days? || period_id? || description? || begin_time? || end_time?
end
Thanks for any feedback!