Skip to content
This repository

make the input method can accept a block #887

Closed
wants to merge 1 commit into from

2 participants

左永辉 Justin French
左永辉

Sometimes I need to add something other into the input wrapper <li>, so it can be convenient if the input can be called with a block, and the block code is inserted after the input in the page .

Justin French
Owner

Hi, thanks for the patch, but I'm nervous about accepting this right now without full consideration — it would effectively shut the door on what else we can use the block for.

My current approach is to define a custom input and incorporate the extra content there instead. Closing for now, sorry I don't have more time to go deep on this right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 21, 2012
左永辉 zuozuo make input to accept a block 5732056
This page is out of date. Refresh to see the latest.
1  .gitignore
@@ -15,3 +15,4 @@ Gemfile.lock
15 15 doc/
16 16 tmp
17 17 gemfiles/*.lock
  18 +tags
4 lib/formtastic/helpers/input_helper.rb
@@ -236,6 +236,10 @@ def input(method, options = {})
236 236 options = options.dup # Allow options to be shared without being tainted by Formtastic
237 237 options[:as] ||= default_input_type(method, options)
238 238
  239 + if block_given?
  240 + options[:block_content] = template.capture(&block)
  241 + end
  242 +
239 243 klass = input_class(options[:as])
240 244
241 245 klass.new(self, template, @object, @object_name, method, options).to_html
2  lib/formtastic/inputs/base/wrapping.rb
@@ -8,7 +8,7 @@ module Wrapping
8 8 # errors before the body of the input).
9 9 def input_wrapping(&block)
10 10 template.content_tag(:li,
11   - [template.capture(&block), error_html, hint_html].join("\n").html_safe,
  11 + [template.capture(&block), options[:block_content], error_html, hint_html].join("\n").html_safe,
12 12 wrapper_html_options
13 13 )
14 14 end

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.