bootstrap-form 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -39,9 +39,25 @@ You get something like this:
39
39
 
40
40
  Pretty straight forward.
41
41
 
42
- ## Other helpers
42
+ ## Custom Label
43
43
 
44
- So far, I have implemented the following helpers:
44
+ You can specify a custom label for the input by setting the label
45
+ option:
46
+
47
+ form_for @account do |f|
48
+ f.bootstrap_text_field :name, :label => 'A custom label'
49
+ end
50
+
51
+ Then, you get something like this:
52
+
53
+ <div class="clearfix">
54
+ <label for="account_name">A custom label</label>
55
+ <div class="input">
56
+ <input class="xlarge" id="account_name" name="account_name" size="30" type="text">
57
+ </div>
58
+ </div>
59
+
60
+ ## Current Helpers List
45
61
 
46
62
  * bootstrap_text_field
47
63
  * bootstrap_password_field
@@ -49,13 +65,13 @@ So far, I have implemented the following helpers:
49
65
  * bootstrap_file_field
50
66
  * bootstrap_text_area
51
67
 
52
- Expect more in the near future
53
-
54
68
  ## Error handling
55
69
 
56
70
  All fields will automatically add the classes to show errors with the Twitter
57
71
  bootstrap styles.
58
72
 
59
- # TODO
73
+ ## TODO
74
+
75
+ Coming soon:
60
76
 
61
77
  * More form inputs
@@ -24,7 +24,7 @@ module ActionView
24
24
  def bootstrap_clearfix_wrap(object_name, method, content, options={})
25
25
  error_messages = options[:object].errors[method]
26
26
  clearfix_tag = error_messages.empty? ? 'clearfix' : 'clearfix error'
27
- content_tag(:div, label(object_name, method) +
27
+ content_tag(:div, label(object_name, method, options[:label]) +
28
28
  content_tag(:div, content + inline_help_tag(error_messages), :class => 'input'),
29
29
  :class => clearfix_tag)
30
30
  end
@@ -1,5 +1,5 @@
1
1
  module Bootstrap
2
2
  module Form
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -13,6 +13,18 @@ class FormHelperTest < ActionView::TestCase
13
13
  assert_equal expected_code, bootstrap_clearfix_wrap(:post, :name, content, options)
14
14
  end
15
15
 
16
+ def test_bootstrap_clearfix_wrap_with_label
17
+ object = mock
18
+ errors = { :name => [] }
19
+ options = { :object => object, :label => "Custom" }
20
+ content = ::ActiveSupport::SafeBuffer.new('content')
21
+ stub(object).errors { errors }
22
+ stub(object).name { 'Object Name' }
23
+
24
+ expected_code = %{<div class="clearfix"><label for="post_name">Custom</label><div class="input">content</div></div>}
25
+ assert_equal expected_code, bootstrap_clearfix_wrap(:post, :name, content, options)
26
+ end
27
+
16
28
  def test_bootstrap_clearfix_wrap_with_errors
17
29
  object = mock
18
30
  errors = { :name => ["can't be blank"] }
@@ -70,4 +82,5 @@ class FormHelperTest < ActionView::TestCase
70
82
  mock(self).bootstrap_clearfix_wrap(:post, :description, text_area, options.dup) { html }
71
83
  assert_equal html, bootstrap_text_area(:post, :description, options)
72
84
  end
85
+
73
86
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-13 00:00:00.000000000 Z
12
+ date: 2011-09-15 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &70138191484300 !ruby/object:Gem::Requirement
16
+ requirement: &70310125359080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70138191484300
24
+ version_requirements: *70310125359080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: actionpack
27
- requirement: &70138191483800 !ruby/object:Gem::Requirement
27
+ requirement: &70310125358580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70138191483800
35
+ version_requirements: *70310125358580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest
38
- requirement: &70138191483420 !ruby/object:Gem::Requirement
38
+ requirement: &70310125358200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70138191483420
46
+ version_requirements: *70310125358200
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rr
49
- requirement: &70138191482960 !ruby/object:Gem::Requirement
49
+ requirement: &70310125357740 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70138191482960
57
+ version_requirements: *70310125357740
58
58
  description: Twitter Bootstrap Form helpers
59
59
  email:
60
60
  - david@crowdint.com