Open resistorsoftware opened 14 years ago
WIll review this when I get time, feel free to help me out by creating a app/spec that re-produce this behaviour.
resistorsoftware said:
Hi,
For sure there is a problem... using the belongs_to association causes an error in the way the javascript tries to hook in to the validation. I am sure it is simply off by an _id or something.
I will look into helping you for sure...
i'm seeing a similar problem here... maybe it's a result of formtastic wrapping labels around the radio input elements (instead of putting them after like validatious examples show) - just a guess
Problem seems to from my setup as follows: Post belongs_to :category. I use HAML for templates.
class Post < ActiveRecord::Base belongs_to :category validates_presence_of :category
So now, in Formtastic I am displaying some radio buttons for category via the Formtastic setup:
which generates the radio buttons. Pressing submit however does not validate that a radio was selected, and by default none is selected.
The generated HTML is:
So I am stuck here. I see no class of "presence" added to my radio's. That seems to be the problem, but I am not sure why.
If I change to validation_presence_of :category_id
to ensure a category radio button is picked, a Javascript error is thrown about an illegal character... but the radios are rendered with the "presence" class.
How to get radio's generated like this to validate?