Question

I have a such form:

= simple_form_for @post, validate: true do |f|
  = f.association :topic, input_html: {class: "chosen"}
  = f.submit :submit

and client_side_validations-simple_form (2.1.0). Topic_id's presence is set as true.

How to make it work together?

Now errors are loading only after submitting form and re-rendering template.

Was it helpful?

Solution

So I've solved an issue. It didn't worked because validation was defined this way:

validates :topic, presence: true

But client-side-validations expects validations that applied to topic_id attribute.

The solution is to apply validation to association id, not to association:

validates :topic_id, presence: true
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top