Skip to content
Browse files

Wrapped semantic_remote_form_for to allow for unobstrusive javascript…

… in rails3
  • Loading branch information...
1 parent d52d829 commit e27dc9f0c687a0304e62b844e0fa198c8549b3aa @yabawock yabawock committed Apr 15, 2010
Showing with 14 additions and 0 deletions.
  1. +2 −0 CHANGELOG
  2. +12 −0 lib/formtastic.rb
View
2 CHANGELOG
@@ -1,6 +1,8 @@
(HEAD)
* Added railtie to perform initialization tasks after the rails git framework is available (rails3)
* Fixed inputs_for_nested_attributes only appending to the output buffer
+* Mark strings as HTML safe depending on environment, adapted from haml 2.2 solution (rails3)
+* Wrap semantic_remote_form_for to allow for unobstrusive javascript (rails3)
0.9.8
View
12 lib/formtastic.rb
@@ -1685,6 +1685,16 @@ def with_custom_field_error_proc(&block)
result
end
+ def semantic_remote_form_for_wrapper(record_or_name_or_array, *args, &proc)
+ options = args.extract_options!
+ if self.respond_to? :remote_form_for
+ semantic_remote_form_for_real(record_or_name_or_array, *(args << options), &proc)
+ else
+ options[:remote] = true
+ semantic_form_for(record_or_name_or_array, *(args << options), &proc)
+ end
+ end
+
[:form_for, :fields_for, :remote_form_for].each do |meth|
module_eval <<-END_SRC, __FILE__, __LINE__ + 1
def semantic_#{meth}(record_or_name_or_array, *args, &proc)
@@ -1707,6 +1717,8 @@ def semantic_#{meth}(record_or_name_or_array, *args, &proc)
end
END_SRC
end
+ alias :semantic_remote_form_for_real :semantic_remote_form_for
+ alias :semantic_remote_form_for :semantic_remote_form_for_wrapper
alias :semantic_form_remote_for :semantic_remote_form_for
end

0 comments on commit e27dc9f

Please sign in to comment.
Something went wrong with that request. Please try again.