Sha256: 84b3a9cb127de91af599fad5fb35411b3fdec0c2640940bd680e99bc13a9d71d
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require 'bootstrap_form' module BootstrapValidatorRails module Helper def bootstrap_validation_form_for(object, options = {}, &block) ActiveSupport::Deprecation.warn("bootstrap_validation_form_for is deprecated. Use bv_form_for instead.") bv_form_for(object, options, &block) end def bv_form_for(object, options = {}, &block) options.reverse_merge!({builder: BootstrapValidatorRails::FormBuilder}) bootstrap_form_for(object, options, &block) end def bv_options_for(object) validators = object.class.validators bv_options = { fields: {} } validators.each do |validator| methods = validator.attributes methods.each do |method| @generator = BootstrapValidatorRails::Validators::Generator.new(object, validator, method) json = @generator.generate_json bv_options[:fields].deep_merge! json end end bv_options.to_json.html_safe end def bv_javascript_for(object) javascript_tag(" $(document).ready(function() { bv_form('.bv_form', #{bv_options_for(object)}) }); ") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bootstrap_validator_rails-0.7.0 | lib/bootstrap_validator_rails/helper.rb |