Module: ValidationSyncFormHelper

Defined in:
app/helpers/validation_sync_form_helper.rb

Instance Method Summary collapse

Instance Method Details

#form_for(record, options = {}, &block) ⇒ Object

Override the default form_for method to include a data-sync-validations attribute, set to true / false returns html



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/validation_sync_form_helper.rb', line 9

def form_for(record, options = {}, &block)
	# If the html_options / data hashes are not
	# set, then let's add them as empty hashes
	options[:html] ||= {}
	options[:html][:data] ||= {}

  # Default to validate = false
  options[:validate] ||= false

	# Add our data-sync-validations attribute
 options[:html][:data][:sync_validations] = options[:validate].to_s

  # Let the Rails defaults take it from here
  super
end