9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/signed_form/action_view/form_helper.rb', line 9
def form_for(record, options = {}, &block)
if options[:signed].nil? && !SignedForm.options[:signed] || !options[:signed].nil? && !options[:signed]
return super
end
options = SignedForm.options.merge options
options[:builder] ||= ::ActionView::Helpers::FormBuilder
ancestors = options[:builder].ancestors
if !ancestors.include?(::ActionView::Helpers::FormBuilder) && !ancestors.include?(SignedForm::FormBuilder)
raise "Form signing not supported on builders that don't subclass ActionView::Helpers::FormBuilder or include SignedForm::FormBuilder"
elsif !ancestors.include?(SignedForm::FormBuilder)
options[:builder] = SignedForm::FormBuilder::BUILDERS[options[:builder]]
end
super record, options do |f|
output = capture(f, &block)
f.form_signature_tag + output
end
end
|