Permalink
Browse files

Merge pull request #857 from justinfrench/838-strings-instead-of-symbols

Coerce `method` into a `Symbol` if it's a `String`
  • Loading branch information...
2 parents c462c09 + e7e90c6 commit 7aee923ee4bce727ca872c7f0edae9267bc0377e @justinfrench committed Jun 6, 2012
Showing with 11 additions and 0 deletions.
  1. +1 −0 lib/formtastic/helpers/input_helper.rb
  2. +10 −0 spec/inputs/label_spec.rb
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|

0 comments on commit 7aee923

Please sign in to comment.