Skip to content

Instantly share code, notes, and snippets.

@mattfordham
Created September 15, 2011 21:27
Show Gist options
  • Save mattfordham/1220524 to your computer and use it in GitHub Desktop.
Save mattfordham/1220524 to your computer and use it in GitHub Desktop.
Conditional validations breaks client side validation
class Entry < ActiveRecord::Base
validates :first_name, :presence => true, :length => {:maximum => 50}, :if => :condition?
def condition?
return true
end
end
= simple_form_for @entry, :validate => true do |f|
= f.input :first_name, :validate => true, :required => true
@bcardarella
Copy link

You have to do:

= f.input :first_name, :input_html => { :validate => true }, :required => true

This is outlined in the SimpleForm wiki page:

https://github.com/bcardarella/client_side_validations/wiki/SimpleForm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment