formtastic 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ 2.1.1
2
+
3
+ * Documentation improvements and updates
4
+ * Fixed that the required string was appended to the label over and over due to localizer caching
5
+ * Fixed that the checkbox's `name` attribute was included in the attributes of the matching label element on boolean fields
6
+
7
+ 2.1.0
8
+
9
+ * no changes
10
+
1
11
  2.1.0.rc
2
12
 
3
13
  * documentation improvements
data/README.textile CHANGED
@@ -317,14 +317,14 @@ Customize the default class used for hints on each attribute or globally in the
317
317
  Many inputs provide a collection of options to choose from (like @:select@, @:radio@, @:check_boxes@, @:boolean@). In many cases, Formtastic can find choices through the model associations, but if you want to use your own set of choices, the @:collection@ option is what you want. You can pass in an Array of objects, an array of Strings, a Hash... Throw almost anything at it! Examples:
318
318
 
319
319
  <pre>
320
- f.input :authors, :as => :check_boxes, :collection => User.find(:all, :order => "last_name ASC")
320
+ f.input :authors, :as => :check_boxes, :collection => User.order("last_name ASC").all
321
321
  f.input :authors, :as => :check_boxes, :collection => current_user.company.users.active
322
322
  f.input :authors, :as => :check_boxes, :collection => [@justin, @kate]
323
323
  f.input :authors, :as => :check_boxes, :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
324
- f.input :author, :as => :select, :collection => Author.find(:all)
324
+ f.input :author, :as => :select, :collection => Author.all
325
325
  f.input :author, :as => :select, :collection => { @justin.name => @justin.id, @kate.name => @kate.id }
326
326
  f.input :author, :as => :select, :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
327
- f.input :author, :as => :radio, :collection => User.find(:all)
327
+ f.input :author, :as => :radio, :collection => User.all
328
328
  f.input :author, :as => :radio, :collection => [@justin, @kate]
329
329
  f.input :author, :as => :radio, :collection => { @justin.name => @justin.id, @kate.name => @kate.id }
330
330
  f.input :author, :as => :radio, :collection => ["Justin", "Kate", "Amelia", "Gus", "Meg"]
@@ -20,7 +20,7 @@ module Formtastic
20
20
  end
21
21
 
22
22
  def label_text
23
- ((localized_label || humanized_method_name) << requirement_text).html_safe
23
+ ((localized_label || humanized_method_name) + requirement_text).html_safe
24
24
  end
25
25
 
26
26
  # TODO: why does this need to be memoized in order to make the inputs_spec tests pass?
@@ -57,8 +57,9 @@ module Formtastic
57
57
 
58
58
  input_html_options.merge(
59
59
  prev.merge(
60
- :id => nil,
61
- :for => input_html_options[:id]
60
+ :id => nil,
61
+ :name => nil,
62
+ :for => input_html_options[:id]
62
63
  )
63
64
  )
64
65
  end
@@ -101,4 +102,4 @@ module Formtastic
101
102
 
102
103
  end
103
104
  end
104
- end
105
+ end
@@ -1,3 +1,3 @@
1
1
  module Formtastic
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
@@ -29,6 +29,10 @@ describe 'boolean input' do
29
29
  output_buffer.should_not have_tag('form li label input[@type="hidden"]', :count => 1) # invalid HTML5
30
30
  end
31
31
 
32
+ it 'should not add a "name" attribute to the label' do
33
+ output_buffer.should_not have_tag('form li label[@name]')
34
+ end
35
+
32
36
  it 'should generate a checkbox input' do
33
37
  output_buffer.should have_tag('form li label input')
34
38
  output_buffer.should have_tag('form li label input#post_allow_comments')
@@ -10,6 +10,28 @@ describe 'Formtastic::FormBuilder#label' do
10
10
  mock_everything
11
11
  end
12
12
 
13
+ it 'should add "required string" only once with caching enabled' do
14
+ with_config :i18n_cache_lookups, true do
15
+ ::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => "I18n title" } } } }
16
+ required_string = "[req_string]"
17
+ default_required_str = Formtastic::FormBuilder.required_string
18
+ Formtastic::FormBuilder.required_string = required_string
19
+
20
+ concat(semantic_form_for(@new_post) do |builder|
21
+ builder.input(:title, :required => true, :label => true)
22
+ end)
23
+ output_buffer.replace ''
24
+ concat(semantic_form_for(@new_post) do |builder|
25
+ builder.input(:title, :required => true, :label => true)
26
+ end)
27
+
28
+ ::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => nil } } } }
29
+ Formtastic::FormBuilder.required_string = default_required_str
30
+
31
+ output_buffer.scan(required_string).count.should == 1
32
+ end
33
+ end
34
+
13
35
  it 'should humanize the given attribute' do
14
36
  concat(semantic_form_for(@new_post) do |builder|
15
37
  builder.input(:title)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formtastic
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 0
10
- version: 2.1.0
9
+ - 1
10
+ version: 2.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin French
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-25 00:00:00 +11:00
18
+ date: 2012-03-03 00:00:00 +11:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency