bootstrap-form 1.0.0 → 3.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -2
- data/Gemfile.rails.3.2 +7 -0
- data/Gemfile.rails.4.0 +7 -0
- data/LICENSE +20 -0
- data/README.md +10 -10
- data/bootsrap-form.gemspec +3 -3
- data/lib/bootstrap-form/form_helper.rb +13 -6
- data/lib/bootstrap-form/version.rb +1 -1
- data/test/lib/action_view/helpers/form_helper_test.rb +6 -6
- data/test/test_helper.rb +0 -4
- metadata +16 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 550f8154589e3409ab3f1ea4e527ea00715702f3
|
4
|
+
data.tar.gz: 9f58ff608b6d2e3a82704f79169794a4377158ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac6e895c213b1b503e852accf572e6ac30436390c4759ae9e5c1872dbf18fe97724fbf4dd5057ec4be9f802c2d302f36a71503b15727170405361840cc08e56c
|
7
|
+
data.tar.gz: 7d208337c7fb92dd6a9bc0327293e0a13b5ab767a8d61a913e44cd5601a88a427c252a25a3169b140e33b56f451ee7e01d9a5df2ac4c2cee83545c6a1509d19a
|
data/.travis.yml
CHANGED
data/Gemfile.rails.3.2
ADDED
data/Gemfile.rails.4.0
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 David Padilla
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# Bootstrap Form
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/dabit/bootstrap-form.png?branch=master)](https://travis-ci.org/dabit/bootstrap-form)
|
4
|
+
|
5
|
+
Form Helpers to make your form inputs [look like this](http://twitter.github.io/bootstrap/base-css.html#forms).
|
4
6
|
|
5
7
|
Helps you to create beautiful mocks really quickly.
|
6
8
|
|
7
|
-
Works with Bootstrap
|
9
|
+
Works with Bootstrap 3 and Rails 3.2+ (including Rails 4)
|
10
|
+
|
11
|
+
For older versions of Bootstrap use version 1.0.x of this gem.
|
8
12
|
|
9
13
|
## Usage
|
10
14
|
|
@@ -32,11 +36,9 @@ You write this:
|
|
32
36
|
|
33
37
|
You get something like this:
|
34
38
|
|
35
|
-
<div class="
|
39
|
+
<div class="form-group">
|
36
40
|
<label class="control-label" for="account_name">Name</label>
|
37
|
-
<
|
38
|
-
<input id="account_name" name="account_name" size="30" type="text">
|
39
|
-
</div>
|
41
|
+
<input class="form-control" id="account_name" name="account_name" size="30" type="text">
|
40
42
|
</div>
|
41
43
|
|
42
44
|
Pretty straight forward.
|
@@ -52,11 +54,9 @@ option:
|
|
52
54
|
|
53
55
|
Then, you get something like this:
|
54
56
|
|
55
|
-
<div class="
|
57
|
+
<div class="form-group">
|
56
58
|
<label class="control-label" for="account_name">A custom label</label>
|
57
|
-
<
|
58
|
-
<input id="account_name" name="account_name" size="30" type="text">
|
59
|
-
</div>
|
59
|
+
<input class="form-control" id="account_name" name="account_name" size="30" type="text">
|
60
60
|
</div>
|
61
61
|
|
62
62
|
## Current Helpers List
|
data/bootsrap-form.gemspec
CHANGED
@@ -19,9 +19,9 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
|
22
|
-
s.add_dependency 'railties', '
|
23
|
-
s.add_dependency 'actionpack', '
|
22
|
+
s.add_dependency 'railties', '> 3.2'
|
23
|
+
s.add_dependency 'actionpack', '> 3.2'
|
24
24
|
|
25
|
-
s.add_development_dependency "minitest"
|
25
|
+
s.add_development_dependency "minitest", "~> 4.7.5"
|
26
26
|
s.add_development_dependency "rr"
|
27
27
|
end
|
@@ -5,40 +5,47 @@ module ActionView
|
|
5
5
|
BOOTSTRAP_OPTIONS = [:label, :hint].freeze
|
6
6
|
|
7
7
|
def bootstrap_text_field(object_name, method, options={})
|
8
|
+
options[:class] = (options[:class] ? options[:class] + " form-control" : "form-control")
|
8
9
|
bootstrap_control_group_wrap(object_name, method, text_field(object_name, method, extract_input_options(options)), options)
|
9
10
|
end
|
10
11
|
|
11
12
|
def bootstrap_email_field(object_name, method, options={})
|
13
|
+
options[:class] = (options[:class] ? options[:class] + " form-control" : "form-control")
|
12
14
|
bootstrap_control_group_wrap(object_name, method, email_field(object_name, method, extract_input_options(options)), options)
|
13
15
|
end
|
14
16
|
|
15
17
|
def bootstrap_password_field(object_name, method, options={})
|
18
|
+
options[:class] = (options[:class] ? options[:class] + " form-control" : "form-control")
|
16
19
|
bootstrap_control_group_wrap(object_name, method, password_field(object_name, method, extract_input_options(options)), options)
|
17
20
|
end
|
18
21
|
|
19
22
|
def bootstrap_collection_select(object_name, method, collection, value_method, text_method, options = {}, html_options = {})
|
23
|
+
html_options[:class] = (html_options[:class] ? html_options[:class] + " form-control" : "form-control")
|
20
24
|
bootstrap_control_group_wrap(object_name, method, collection_select(object_name, method, collection, value_method, text_method, extract_input_options(options), html_options), options)
|
21
25
|
end
|
22
26
|
|
23
|
-
def bootstrap_select(object_name, method, choices, options, html_options)
|
27
|
+
def bootstrap_select(object_name, method, choices, options={}, html_options={})
|
28
|
+
html_options[:class] = (html_options[:class] ? html_options[:class] + " form-control" : "form-control")
|
24
29
|
bootstrap_control_group_wrap(object_name, method, select(object_name, method, choices, extract_input_options(options), html_options), options)
|
25
30
|
end
|
26
31
|
|
27
32
|
def bootstrap_file_field(object_name, method, options={})
|
33
|
+
options[:class] = (options[:class] ? options[:class] + " form-control" : "form-control")
|
28
34
|
bootstrap_control_group_wrap(object_name, method, file_field(object_name, method, extract_input_options(options)), options)
|
29
35
|
end
|
30
36
|
|
31
37
|
def bootstrap_text_area(object_name, method, options={})
|
38
|
+
options[:class] = (options[:class] ? options[:class] + " form-control" : "form-control")
|
32
39
|
bootstrap_control_group_wrap(object_name, method, text_area(object_name, method, extract_input_options(options)), options)
|
33
40
|
end
|
34
41
|
|
35
42
|
def bootstrap_control_group_wrap(object_name, method, content, options={})
|
36
|
-
error_messages
|
37
|
-
control_group_tag
|
38
|
-
inline_help
|
43
|
+
error_messages = options[:object].errors[method]
|
44
|
+
control_group_tag = error_messages.blank? ? 'form-group' : 'form-group has-error'
|
45
|
+
inline_help = inline_help_tag(error_messages.presence || options[:hint])
|
39
46
|
|
40
47
|
content_tag(:div, label(object_name, method, options[:label], :class => 'control-label') +
|
41
|
-
|
48
|
+
content + inline_help,
|
42
49
|
:class => control_group_tag)
|
43
50
|
end
|
44
51
|
|
@@ -46,7 +53,7 @@ module ActionView
|
|
46
53
|
messages = Array.wrap(messages)
|
47
54
|
return '' if messages.empty?
|
48
55
|
message_span = ActiveSupport::SafeBuffer.new(" #{messages.to_sentence}")
|
49
|
-
content_tag(:span, message_span, :class => 'help-
|
56
|
+
content_tag(:span, message_span, :class => 'help-block')
|
50
57
|
end
|
51
58
|
|
52
59
|
private
|
@@ -9,7 +9,7 @@ class FormHelperTest < ActionView::TestCase
|
|
9
9
|
stub(object).errors { errors }
|
10
10
|
stub(object).name { 'Object Name' }
|
11
11
|
|
12
|
-
expected_code = %{<div class="
|
12
|
+
expected_code = %{<div class="form-group"><label class="control-label" for="post_name">Name</label>content</div>}
|
13
13
|
assert_equal expected_code, bootstrap_control_group_wrap(:post, :name, content, options)
|
14
14
|
end
|
15
15
|
|
@@ -21,7 +21,7 @@ class FormHelperTest < ActionView::TestCase
|
|
21
21
|
stub(object).errors { errors }
|
22
22
|
stub(object).name { 'Object Name' }
|
23
23
|
|
24
|
-
expected_code = %{<div class="
|
24
|
+
expected_code = %{<div class="form-group"><label class="control-label" for="post_name">Custom</label>content</div>}
|
25
25
|
assert_equal expected_code, bootstrap_control_group_wrap(:post, :name, content, options)
|
26
26
|
end
|
27
27
|
|
@@ -33,7 +33,7 @@ class FormHelperTest < ActionView::TestCase
|
|
33
33
|
stub(object).errors { errors }
|
34
34
|
stub(object).name { 'Object Name' }
|
35
35
|
|
36
|
-
expected_code = %{<div class="
|
36
|
+
expected_code = %{<div class="form-group has-error"><label class="control-label" for="post_name">Name</label>content<span class="help-block"> can't be blank</span></div>}
|
37
37
|
assert_equal expected_code, bootstrap_control_group_wrap(:post, :name, content, options)
|
38
38
|
end
|
39
39
|
|
@@ -45,7 +45,7 @@ class FormHelperTest < ActionView::TestCase
|
|
45
45
|
stub(object).errors { errors }
|
46
46
|
stub(object).name { 'Object Name' }
|
47
47
|
|
48
|
-
expected_code = %{<div class="
|
48
|
+
expected_code = %{<div class="form-group has-error"><label class="control-label" for="post_name">Name</label>content<span class="help-block"> has already been taken, is reserved, and must be odd</span></div>}
|
49
49
|
assert_equal expected_code, bootstrap_control_group_wrap(:post, :name, content, options)
|
50
50
|
end
|
51
51
|
|
@@ -57,7 +57,7 @@ class FormHelperTest < ActionView::TestCase
|
|
57
57
|
stub(object).errors { errors }
|
58
58
|
stub(object).name { 'Object Name' }
|
59
59
|
|
60
|
-
expected_code = %{<div class="
|
60
|
+
expected_code = %{<div class="form-group"><label class="control-label" for="post_name">Name</label>content<span class="help-block"> format matters</span></div>}
|
61
61
|
assert_equal expected_code, bootstrap_control_group_wrap(:post, :name, content, options)
|
62
62
|
end
|
63
63
|
|
@@ -69,7 +69,7 @@ class FormHelperTest < ActionView::TestCase
|
|
69
69
|
stub(object).errors { errors }
|
70
70
|
stub(object).name { 'Object Name' }
|
71
71
|
|
72
|
-
expected_code = %{<div class="
|
72
|
+
expected_code = %{<div class="form-group has-error"><label class="control-label" for="post_name">Name</label>content<span class="help-block"> can't be blank</span></div>}
|
73
73
|
assert_equal expected_code, bootstrap_control_group_wrap(:post, :name, content, options)
|
74
74
|
end
|
75
75
|
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Padilla
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - '
|
17
|
+
- - '>'
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - '
|
24
|
+
- - '>'
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '
|
31
|
+
- - '>'
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '3.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '
|
38
|
+
- - '>'
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 4.7.5
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 4.7.5
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rr
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,6 +76,9 @@ files:
|
|
76
76
|
- .gitignore
|
77
77
|
- .travis.yml
|
78
78
|
- Gemfile
|
79
|
+
- Gemfile.rails.3.2
|
80
|
+
- Gemfile.rails.4.0
|
81
|
+
- LICENSE
|
79
82
|
- README.md
|
80
83
|
- Rakefile
|
81
84
|
- bootsrap-form.gemspec
|
@@ -98,12 +101,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
101
|
version: '0'
|
99
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
103
|
requirements:
|
101
|
-
- - '
|
104
|
+
- - '>'
|
102
105
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
106
|
+
version: 1.3.1
|
104
107
|
requirements: []
|
105
108
|
rubyforge_project: bootstrap-form
|
106
|
-
rubygems_version: 2.0.
|
109
|
+
rubygems_version: 2.0.3
|
107
110
|
signing_key:
|
108
111
|
specification_version: 4
|
109
112
|
summary: Twitter Bootstrap Form helpers
|