public

custom formbuilders for client side validations

  • Download Gist
rails.validations.custom.formbuilders.js
JavaScript
1 2 3 4 5 6 7 8 9 10
// rails.validations.custom.formbuilder.js
// Assuming that your custom Formtastic FormBuilder class is called 'MyCustomFormBuilderClass'
clientSideValidations.formBuilders['MyCustomFormBuilderClass'] = {
add: function(element, settings, message) {
clientSideValidations.formBuilders['Formtastic::SemanticFormBuilder'].add(element, settings, message);
},
remove: function(element, settings, message) {
clientSideValidations.formBuilders['Formtastic::SemanticFormBuilder'].remove(element, settings, message);
}
}

After wondering why it did not work for a while, I did a s/formbuilders/formBuilders/ and was illuminated :-)

in case anyone else winds up here, note that you'll need to change clientSideValidations to ClientSideValidations (uppercase). Other than that still seems to work.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.