Moved from making a default form builder to aliasing the form_tag function in the form helper.
This commit is contained in:
parent
f39a2f1422
commit
6975b5abd7
@ -1,11 +1,12 @@
|
|||||||
require "sisyphus-rails/version"
|
require "sisyphus-rails/version"
|
||||||
require "sisyphus-rails/engine"
|
require "sisyphus-rails/engine"
|
||||||
require "sisyphus-rails/form_helper"
|
# require "sisyphus-rails/form_helper"
|
||||||
|
require "sisyphus-rails/form_tag_helper"
|
||||||
|
|
||||||
module Sisyphus
|
module Sisyphus
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if defined?(ActionView::Base)
|
# if defined?(ActionView::Base)
|
||||||
ActionView::Base.default_form_builder = Sisyphus::FormBuilder
|
# ActionView::Base.default_form_builder = Sisyphus::FormBuilder
|
||||||
end
|
# end
|
@ -1,8 +0,0 @@
|
|||||||
module Sisyphus
|
|
||||||
class FormBuilder < ActionView::Helpers::FormBuilder
|
|
||||||
def initialize(object_name, object, template, options, block=nil)
|
|
||||||
super
|
|
||||||
@template.output_buffer << "<script type=\"text/javascript\">$(document).ready(function() {$('##{self.options[:html][:id]}').sisyphus();});</script>".html_safe
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
18
lib/sisyphus-rails/form_tag_helper.rb
Normal file
18
lib/sisyphus-rails/form_tag_helper.rb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module ActionView
|
||||||
|
module Helpers
|
||||||
|
module FormTagHelper
|
||||||
|
|
||||||
|
def form_tag_with_sisyphus(url_for_options = {}, options = {}, &block)
|
||||||
|
buf = ActiveSupport::SafeBuffer.new
|
||||||
|
|
||||||
|
if options.has_key?(:id)
|
||||||
|
buf.safe_concat("<script type=\"text/javascript\">$(document).ready(function() {$('##{options[:id]}').sisyphus();});</script>")
|
||||||
|
end
|
||||||
|
|
||||||
|
buf << form_tag_without_sisyphus(url_for_options, options, &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
alias_method_chain :form_tag, :sisyphus
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user