Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

make the input method can accept a block #887

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+6 −1
Split
View
@@ -15,3 +15,4 @@ Gemfile.lock
doc/
tmp
gemfiles/*.lock
+tags
@@ -236,6 +236,10 @@ def input(method, options = {})
options = options.dup # Allow options to be shared without being tainted by Formtastic
options[:as] ||= default_input_type(method, options)
+ if block_given?
+ options[:block_content] = template.capture(&block)
+ end
+
klass = input_class(options[:as])
klass.new(self, template, @object, @object_name, method, options).to_html
@@ -8,7 +8,7 @@ module Wrapping
# errors before the body of the input).
def input_wrapping(&block)
template.content_tag(:li,
- [template.capture(&block), error_html, hint_html].join("\n").html_safe,
+ [template.capture(&block), options[:block_content], error_html, hint_html].join("\n").html_safe,
wrapper_html_options
)
end