Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

coerce method into a sym if it's a String #838

  • Loading branch information...
commit e7e90c60c864f03794a068b096ee366fb86269d0 1 parent f68d4c8
@justinfrench authored
View
1  lib/formtastic/helpers/input_helper.rb
@@ -232,6 +232,7 @@ module InputHelper
# @todo Many many more examples. Some of the detail probably needs to be pushed out to the relevant methods too.
# @todo More i18n examples.
def input(method, options = {})
+ method = method.to_sym if method.is_a?(String)
options = options.dup # Allow options to be shared without being tainted by Formtastic
options[:as] ||= default_input_type(method, options)
View
10 spec/inputs/label_spec.rb
@@ -38,6 +38,16 @@
end)
output_buffer.should have_tag('label', /Title/)
end
+
+ it 'should use i18n instead of the method name when method given as a String' do
+ with_config :i18n_cache_lookups, true do
+ ::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => "I18n title" } } } }
+ concat(semantic_form_for(@new_post) do |builder|
+ builder.input("title")
+ end)
+ output_buffer.should have_tag('label', /I18n title/)
+ end
+ end
it 'should humanize the given attribute for date fields' do
concat(semantic_form_for(@new_post) do |builder|
Please sign in to comment.
Something went wrong with that request. Please try again.