comfy_bootstrap_form 4.0.0.beta2 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +103 -0
- data/.travis.yml +3 -0
- data/Gemfile +6 -2
- data/README.md +63 -25
- data/Rakefile +12 -12
- data/bootstrap_form.gemspec +1 -1
- data/demo/app/controllers/bootstrap_controller.rb +9 -3
- data/demo/app/views/bootstrap/form.html.erb +110 -65
- data/demo/db/schema.rb +3 -0
- data/demo/form_preview_horizontal.png +0 -0
- data/demo/form_preview_horizontal_with_errors.png +0 -0
- data/demo/form_preview_inline.png +0 -0
- data/demo/form_preview_vertical.png +0 -0
- data/lib/bootstrap_form/bootstrap_options.rb +115 -0
- data/lib/bootstrap_form/form_builder.rb +96 -133
- data/lib/bootstrap_form/version.rb +3 -1
- data/lib/bootstrap_form/view_helper.rb +2 -1
- data/lib/bootstrap_form.rb +2 -2
- data/test/bootstrap_form/bootstrap_options_test.rb +114 -0
- data/test/bootstrap_form/fields_test.rb +5 -5
- data/test/bootstrap_form/fields_with_errors_test.rb +10 -8
- data/test/bootstrap_form/form_builder_test.rb +5 -37
- data/test/bootstrap_form/horizontal_form_test.rb +9 -8
- data/test/bootstrap_form/inline_form_test.rb +2 -2
- data/test/bootstrap_form/input_group_test.rb +10 -7
- data/test/bootstrap_form/radios_and_checkboxes_test.rb +19 -20
- data/test/bootstrap_form/submit_test.rb +1 -1
- data/test/bootstrap_form/view_helpers_test.rb +3 -3
- data/test/gemfiles/5.2.gemfile +1 -0
- data/test/test_helper.rb +5 -5
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e259644ff4ca92f7c1ad851f4b49405baf41f12db6f2352d2bc86742d102e678
|
4
|
+
data.tar.gz: 5ff70b67fc490005cb33e0c0d0c0211a3181e67470c8aa22266af299a27c0f0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 214fbf0f8c2003616dd75707c156a4da91bb4d740a186fd7436a980eddc26fde7f0067c7c5e8fe2890451ee5f8005079c89d5ed22ea805b6e4e55a8fbbbf2c64
|
7
|
+
data.tar.gz: d00c03f8af63d13203335322dbe2143100e5bdf0188069d517a8acf30be5861f69fbdefbd6367a52c31e6af8b808454a5dcdcdecfc0535c1b260512e32d759c5
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.2
|
5
|
+
Exclude:
|
6
|
+
- demo/**/*
|
7
|
+
|
8
|
+
# -- Performance ---------------------------------------------------------------
|
9
|
+
Performance/Casecmp:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
# -- Metrics -------------------------------------------------------------------
|
13
|
+
Metrics/PerceivedComplexity:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Metrics/MethodLength:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/MethodLength:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/ParameterLists:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Metrics/LineLength:
|
26
|
+
Max: 120
|
27
|
+
|
28
|
+
Metrics/CyclomaticComplexity:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Metrics/ClassLength:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Metrics/BlockLength:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Metrics/AbcSize:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
# -- Layout --------------------------------------------------------------------
|
41
|
+
Layout/MultilineOperationIndentation:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Layout/MultilineMethodCallIndentation:
|
45
|
+
EnforcedStyle: indented
|
46
|
+
|
47
|
+
Layout/MultilineHashBraceLayout:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Layout/IndentArray:
|
51
|
+
EnforcedStyle: consistent
|
52
|
+
|
53
|
+
Layout/EmptyLinesAroundModuleBody:
|
54
|
+
EnforcedStyle: empty_lines_except_namespace
|
55
|
+
|
56
|
+
Layout/EmptyLinesAroundExceptionHandlingKeywords:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
Layout/EmptyLinesAroundClassBody:
|
60
|
+
EnforcedStyle: empty_lines_except_namespace
|
61
|
+
|
62
|
+
Layout/AlignParameters:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
Layout/AccessModifierIndentation:
|
66
|
+
EnforcedStyle: outdent
|
67
|
+
|
68
|
+
# -- Style ---------------------------------------------------------------------
|
69
|
+
Style/StringLiterals:
|
70
|
+
EnforcedStyle: double_quotes
|
71
|
+
|
72
|
+
Style/RegexpLiteral:
|
73
|
+
EnforcedStyle: percent_r
|
74
|
+
|
75
|
+
Style/Lambda:
|
76
|
+
EnforcedStyle: literal
|
77
|
+
|
78
|
+
Style/IfUnlessModifier:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
Style/GuardClause:
|
82
|
+
Enabled: false
|
83
|
+
|
84
|
+
Style/Documentation:
|
85
|
+
Enabled: false
|
86
|
+
|
87
|
+
Style/DateTime:
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
Style/ClassAndModuleChildren:
|
91
|
+
Enabled: false
|
92
|
+
|
93
|
+
Style/AsciiComments:
|
94
|
+
Enabled: false
|
95
|
+
|
96
|
+
# -- Exceptions ----------------------------------------------------------------
|
97
|
+
Performance/RedundantMerge:
|
98
|
+
Exclude:
|
99
|
+
- 'lib/bootstrap_form/view_helper.rb'
|
100
|
+
|
101
|
+
Naming/AccessorMethodName:
|
102
|
+
Exclude:
|
103
|
+
- 'lib/bootstrap_form/bootstrap_options.rb'
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -5,10 +5,14 @@ gemspec
|
|
5
5
|
# Uncomment and change rails version for testing purposes
|
6
6
|
# gem "rails", "~> 5.2.0.beta2"
|
7
7
|
|
8
|
+
group :development do
|
9
|
+
gem "rubocop", "~> 0.51.0", require: false
|
10
|
+
end
|
11
|
+
|
8
12
|
group :test do
|
9
|
-
gem "
|
13
|
+
gem "coveralls", require: false
|
10
14
|
gem "diffy"
|
11
15
|
gem "equivalent-xml"
|
16
|
+
gem "minitest"
|
12
17
|
gem "sqlite3"
|
13
|
-
gem "coveralls", require: false
|
14
18
|
end
|
data/README.md
CHANGED
@@ -29,11 +29,11 @@ gem "comfy_bootstrap_form", "~> 4.0.0"
|
|
29
29
|
Here's a simple example:
|
30
30
|
|
31
31
|
```erb
|
32
|
-
<%= bootstrap_form_with model: @user do |
|
33
|
-
<%=
|
34
|
-
<%=
|
35
|
-
<%=
|
36
|
-
<%=
|
32
|
+
<%= bootstrap_form_with model: @user do |form| %>
|
33
|
+
<%= form.email_field :email %>
|
34
|
+
<%= form.password_field :password %>
|
35
|
+
<%= form.check_box :remember_me %>
|
36
|
+
<%= form.submit "Log In" %>
|
37
37
|
<% end %>
|
38
38
|
```
|
39
39
|
|
@@ -101,7 +101,7 @@ gem takes care of rendering of labels and inputs for you.
|
|
101
101
|
You may choose to render inputs inline:
|
102
102
|
|
103
103
|
```erb
|
104
|
-
<%= form.collection_check_boxes :choices, Choices.all, :id, :label, bootstrap: {
|
104
|
+
<%= form.collection_check_boxes :choices, Choices.all, :id, :label, bootstrap: {check_inline: true} %>
|
105
105
|
```
|
106
106
|
|
107
107
|
#### Submit
|
@@ -153,32 +153,52 @@ If you need to add a label:
|
|
153
153
|
|
154
154
|
## Bootstrap options
|
155
155
|
|
156
|
-
|
156
|
+
Here's a list of all possible bootstrap options you can pass via `:bootstrap`
|
157
|
+
option that can be attached to the `bootstrap_form_with` and any field helpers
|
158
|
+
inside of it:
|
157
159
|
|
158
|
-
|
159
|
-
|
160
|
-
|
160
|
+
```
|
161
|
+
layout: "vertical"
|
162
|
+
label_col_class: "col-sm-2"
|
163
|
+
control_col_class: "col-sm-10"
|
164
|
+
label_align_class: "text-sm-right"
|
165
|
+
inline_margin_class: "mr-sm-2"
|
166
|
+
label: {}
|
167
|
+
append: nil
|
168
|
+
prepend: nil
|
169
|
+
help: nil
|
170
|
+
check_inline: false
|
171
|
+
```
|
172
|
+
|
173
|
+
Options applied on the form level will apply to all field helpers. Options
|
174
|
+
on field helpers will override form-level options. For example, here's a form
|
175
|
+
where all labels are hidden:
|
161
176
|
|
162
177
|
```erb
|
163
|
-
<%= bootstrap_form_with model: @user, bootstrap: {
|
164
|
-
<%= form.
|
178
|
+
<%= bootstrap_form_with model: @user, bootstrap: {label: {hide: true}} do |form| %>
|
179
|
+
<%= form.email_field :email %>
|
180
|
+
<%= form.text_field :username %>
|
165
181
|
<% end %>
|
166
182
|
```
|
167
183
|
|
168
|
-
|
169
|
-
would look with all the defaults:
|
184
|
+
Here's an example of a form where one field uses different label alignment:
|
170
185
|
|
171
186
|
```erb
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
187
|
+
<%= bootstrap_form_with model: @user do |form| %>
|
188
|
+
<%= form.email_field :email, bootstrap: {label_align_class: "text-sm-left"} %>
|
189
|
+
<%= form.text_field :username %>
|
190
|
+
<% end %>
|
191
|
+
```
|
192
|
+
|
193
|
+
#### Horizontal Form
|
194
|
+
|
195
|
+
By default form is rendered as a stack. Labels are above inputs, and inputs
|
196
|
+
take up 100% of the width. You can change form layout to `horizontal` to put
|
197
|
+
labels and corresponding inputs side by side:
|
198
|
+
|
199
|
+
```erb
|
200
|
+
<%= bootstrap_form_with model: @user, bootstrap: {layout: "horizontal"} do |form| %>
|
201
|
+
<%= form.email_field :email %>
|
182
202
|
<% end %>
|
183
203
|
```
|
184
204
|
|
@@ -188,7 +208,7 @@ You may choose to render form elements in one line. Please note that this layout
|
|
188
208
|
won't render all form elements. Things like errors messages won't show up right.
|
189
209
|
|
190
210
|
```erb
|
191
|
-
<%= bootstrap_form_with url: "/search" do |form| %>
|
211
|
+
<%= bootstrap_form_with url: "/search", bootstrap: {layout: "inline"} do |form| %>
|
192
212
|
<%= form.text_field :query %>
|
193
213
|
<%= form.submit "Search" %>
|
194
214
|
<% end %>
|
@@ -251,6 +271,24 @@ messages show up (see: https://github.com/twbs/bootstrap/issues/25540):
|
|
251
271
|
}
|
252
272
|
```
|
253
273
|
|
274
|
+
## Screenshots
|
275
|
+
|
276
|
+
#### Horizontal
|
277
|
+
|
278
|
+
![Horizontal Form](/demo/form_preview_horizontal.png)
|
279
|
+
|
280
|
+
#### Horizontal With Errors
|
281
|
+
|
282
|
+
![Horizontal Form With Errors](/demo/form_preview_horizontal_with_errors.png)
|
283
|
+
|
284
|
+
#### Vertical
|
285
|
+
|
286
|
+
![Vertical Form](/demo/form_preview_vertical.png)
|
287
|
+
|
288
|
+
#### Inline
|
289
|
+
|
290
|
+
![Inline](/demo/form_preview_inline.png)
|
291
|
+
|
254
292
|
---
|
255
293
|
|
256
294
|
Copyright 2018 Oleg Khabarov, Released under the [MIT License](LICENCE.md)
|
data/Rakefile
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require "bundler/setup"
|
3
3
|
rescue LoadError
|
4
|
-
puts
|
4
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
5
5
|
end
|
6
6
|
|
7
|
-
require
|
7
|
+
require "rdoc/task"
|
8
8
|
|
9
9
|
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir =
|
11
|
-
rdoc.title =
|
12
|
-
rdoc.options <<
|
13
|
-
rdoc.rdoc_files.include(
|
14
|
-
rdoc.rdoc_files.include(
|
10
|
+
rdoc.rdoc_dir = "rdoc"
|
11
|
+
rdoc.title = "BootstrapForm"
|
12
|
+
rdoc.options << "--line-numbers"
|
13
|
+
rdoc.rdoc_files.include("README.md")
|
14
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
15
15
|
end
|
16
16
|
|
17
|
-
require
|
17
|
+
require "bundler/gem_tasks"
|
18
18
|
|
19
|
-
require
|
19
|
+
require "rake/testtask"
|
20
20
|
|
21
21
|
Rake::TestTask.new(:test) do |t|
|
22
|
-
t.libs <<
|
23
|
-
t.pattern =
|
22
|
+
t.libs << "test"
|
23
|
+
t.pattern = "test/**/*_test.rb"
|
24
24
|
t.verbose = false
|
25
25
|
end
|
26
26
|
|
data/bootstrap_form.gemspec
CHANGED
@@ -4,9 +4,15 @@ class BootstrapController < ApplicationController
|
|
4
4
|
@user = User.new(test: "Lorem ipsum")
|
5
5
|
|
6
6
|
@user_with_error = User.new
|
7
|
-
@user_with_error.errors.add(:
|
8
|
-
@user_with_error.errors.add(:
|
9
|
-
@user_with_error.errors.add(:
|
7
|
+
@user_with_error.errors.add(:username, "Username already taken")
|
8
|
+
@user_with_error.errors.add(:email, "Invalid email address")
|
9
|
+
@user_with_error.errors.add(:password, "Another user already uses this password")
|
10
|
+
@user_with_error.errors.add(:color, "Red is the worst color. Choose another.")
|
11
|
+
@user_with_error.errors.add(:bio, "Too much information")
|
12
|
+
@user_with_error.errors.add(:locale, "It's fine, but here's another error")
|
13
|
+
@user_with_error.errors.add(:terms, "You never agreed to Terms and Conditions")
|
14
|
+
@user_with_error.errors.add(:test, "Generic error message")
|
15
|
+
|
10
16
|
end
|
11
17
|
|
12
18
|
end
|
@@ -1,82 +1,127 @@
|
|
1
1
|
<h3>Horizontal Form</h3>
|
2
2
|
|
3
|
-
<%= bootstrap_form_with model: @user, url: "/", bootstrap: {layout: :horizontal} do |form| %>
|
4
|
-
<%= form.email_field :
|
5
|
-
<%= form.email_field :email,
|
6
|
-
<%= form.
|
7
|
-
<%= form.collection_radio_buttons :
|
8
|
-
<%= form.
|
9
|
-
<%= form.
|
10
|
-
<%= form.
|
11
|
-
|
12
|
-
|
13
|
-
<% end %>
|
14
|
-
<%= form.primary "Smash That Button" do %>
|
15
|
-
<a href="/" class="btn btn-link">Unsubcribe</a>
|
3
|
+
<%= bootstrap_form_with model: @user, scope: "user_a", url: "/", bootstrap: {layout: :horizontal} do |form| %>
|
4
|
+
<%= form.email_field :username, placeholder: "AzureDiamond", bootstrap: {prepend: "@"} %>
|
5
|
+
<%= form.email_field :email, placeholder: "you@example.com" %>
|
6
|
+
<%= form.password_field :password, placeholder: "hunter2", bootstrap: {help: "Password should be at least 12 characters long"} %>
|
7
|
+
<%= form.collection_radio_buttons :color, ["red", "green", "blue"], :to_s, :titleize, bootstrap: {check_inline: true, help: "Choose your favorite color"} %>
|
8
|
+
<%= form.text_area :bio, placeholder: "Tell us your life story" %>
|
9
|
+
<%= form.select :locale, [["English", "en"], ["French", "fr"]], {}, bootstrap: {label: {text: "Language"}} %>
|
10
|
+
<%= form.check_box :terms, bootstrap: {label: {text: "I agree to Terms and Conditions"}, help: "By clicking Agree you're also acknowledging that Apple may sew your mouth to a ... "} %>
|
11
|
+
<%= form.primary "Press to Register" do %>
|
12
|
+
<a href="/" class="btn btn-link">Maybe Later</a>
|
16
13
|
<% end %>
|
17
14
|
<% end %>
|
18
15
|
|
19
|
-
<h3>
|
16
|
+
<h3>Horizontal Form With Errors</h3>
|
20
17
|
|
21
|
-
<%= bootstrap_form_with model: @
|
22
|
-
<%= form.email_field :
|
23
|
-
<%= form.
|
24
|
-
<%= form.
|
25
|
-
<%= form.
|
26
|
-
|
27
|
-
|
28
|
-
<%= form.
|
29
|
-
|
18
|
+
<%= bootstrap_form_with model: @user_with_error, scope: "user_b", url: "/", bootstrap: {layout: :horizontal} do |form| %>
|
19
|
+
<%= form.email_field :username, placeholder: "AzureDiamond", bootstrap: {prepend: "@"} %>
|
20
|
+
<%= form.email_field :email, placeholder: "you@example.com" %>
|
21
|
+
<%= form.password_field :password, placeholder: "hunter2", bootstrap: {help: "Password should be at least 12 characters long"} %>
|
22
|
+
<%= form.collection_radio_buttons :color, ["red", "green", "blue"], :to_s, :titleize, bootstrap: {check_inline: true, help: "Choose your favorite color"} %>
|
23
|
+
<%= form.text_area :bio, placeholder: "Tell us your life story" %>
|
24
|
+
<%= form.select :locale, [["English", "en"], ["French", "fr"]], {}, bootstrap: {label: {text: "Language"}} %>
|
25
|
+
<%= form.check_box :terms, bootstrap: {label: {text: "I agree to Terms and Conditions"}, help: "By clicking Agree you're also acknowledging that Apple may sew your mouth to a ... "} %>
|
26
|
+
<%= form.primary "Press to Register" do %>
|
27
|
+
<a href="/" class="btn btn-link">Maybe Later</a>
|
30
28
|
<% end %>
|
31
29
|
<% end %>
|
32
30
|
|
33
|
-
<h3>
|
31
|
+
<h3>Inline Form</h3>
|
34
32
|
|
35
|
-
<%= bootstrap_form_with
|
36
|
-
<%= form.email_field :
|
37
|
-
<%= form.password_field :password, placeholder: "Password"%>
|
38
|
-
<%= form.
|
39
|
-
<%= form.
|
40
|
-
<%= form.file_field :test, bootstrap: {label: {text: "File Field"}} %>
|
41
|
-
<%= form.plaintext :test, bootstrap: {label: {text: "Plain Text"}} %>
|
42
|
-
<%= form.check_box :terms, bootstrap: {label: {text: "Agree to Terms"}} %>
|
43
|
-
<%= form.form_group do %>
|
44
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
45
|
-
tempor incididunt ut labore et dolore magna aliqua.
|
46
|
-
<% end %>
|
47
|
-
<%= form.submit %>
|
33
|
+
<%= bootstrap_form_with scope: :login, url: "/", bootstrap: {layout: :inline, label: {hide: true}} do |form| %>
|
34
|
+
<%= form.email_field :username, placeholder: "Username", bootstrap: {prepend: "@"} %>
|
35
|
+
<%= form.password_field :password, placeholder: "Password" %>
|
36
|
+
<%= form.check_box :remember_me %>
|
37
|
+
<%= form.primary "Sign in", class: "ml-3" %>
|
48
38
|
<% end %>
|
49
39
|
|
50
|
-
<
|
40
|
+
<div class="row">
|
41
|
+
<div class="col-6">
|
42
|
+
<h3>Vertical Form</h3>
|
51
43
|
|
52
|
-
|
53
|
-
<%=
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
44
|
+
<%= bootstrap_form_with model: @user, scope: "user_c", url: "/" do |form| %>
|
45
|
+
<%= form.email_field :username, placeholder: "AzureDiamond", bootstrap: {prepend: "@"} %>
|
46
|
+
<%= form.email_field :email, placeholder: "you@example.com" %>
|
47
|
+
<%= form.password_field :password, placeholder: "hunter2", bootstrap: {help: "Password should be at least 12 characters long"} %>
|
48
|
+
<%= form.collection_radio_buttons :color, ["red", "green", "blue"], :to_s, :titleize, bootstrap: {check_inline: true, help: "Choose your favorite color"} %>
|
49
|
+
<%= form.text_area :bio, placeholder: "Tell us your life story" %>
|
50
|
+
<%= form.select :locale, [["English", "en"], ["French", "fr"]], {}, bootstrap: {label: {text: "Language"}} %>
|
51
|
+
<%= form.check_box :terms, bootstrap: {label: {text: "I agree to Terms and Conditions"}, help: "By clicking Agree you're also acknowledging that Apple may sew your mouth to a ... "} %>
|
52
|
+
<%= form.primary "Press to Register" do %>
|
53
|
+
<a href="/" class="btn btn-link">Maybe Later</a>
|
54
|
+
<% end %>
|
55
|
+
<% end %>
|
56
|
+
</div>
|
57
|
+
<div class="col-6">
|
58
|
+
<h3>With Errors</h3>
|
59
59
|
|
60
|
-
|
60
|
+
<%= bootstrap_form_with model: @user_with_error, scope: "user_c", url: "/" do |form| %>
|
61
|
+
<%= form.email_field :username, placeholder: "AzureDiamond", bootstrap: {prepend: "@"} %>
|
62
|
+
<%= form.email_field :email, placeholder: "you@example.com" %>
|
63
|
+
<%= form.password_field :password, placeholder: "hunter2", bootstrap: {help: "Password should be at least 12 characters long"} %>
|
64
|
+
<%= form.collection_radio_buttons :color, ["red", "green", "blue"], :to_s, :titleize, bootstrap: {check_inline: true, help: "Choose your favorite color"} %>
|
65
|
+
<%= form.text_area :bio, placeholder: "Tell us your life story" %>
|
66
|
+
<%= form.select :locale, [["English", "en"], ["French", "fr"]], {}, bootstrap: {label: {text: "Language"}} %>
|
67
|
+
<%= form.check_box :terms, bootstrap: {label: {text: "I agree to Terms and Conditions"}, help: "By clicking Agree you're also acknowledging that Apple may sew your mouth to a ... "} %>
|
68
|
+
<%= form.primary "Press to Register" do %>
|
69
|
+
<a href="/" class="btn btn-link">Maybe Later</a>
|
70
|
+
<% end %>
|
71
|
+
<% end %>
|
72
|
+
</div>
|
73
|
+
</div>
|
61
74
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
<% end %>
|
75
|
+
<div class="row">
|
76
|
+
<div class="col-6">
|
77
|
+
<h3>Checkboxes and Radio buttons</h3>
|
78
|
+
<% @user.test = "b" %>
|
79
|
+
<%= bootstrap_form_with model: @user, scope: "user_d", url: "/" do |form| %>
|
80
|
+
<%= form.collection_radio_buttons :test, [["a", "Label A"], ["b", "Label B"]], :first, :second %>
|
81
|
+
<%= form.collection_check_boxes :test, [["e", "Label E"], ["f", "Label F"]], :first, :second, bootstrap: {help: "help text"} %>
|
82
|
+
<%= form.collection_radio_buttons :test, ["u", "v", "w"], :to_s, :to_s, bootstrap: {inline: true, label: {text: "Custom Label"}} %>
|
83
|
+
<%= form.collection_check_boxes :test, ["x", "y", "z"], :to_s, :to_s, bootstrap: {inline: true, help: "help text", label: {hide: true}} %>
|
84
|
+
<% end %>
|
85
|
+
</div>
|
86
|
+
<div class="col-6">
|
87
|
+
<h3>With Errors</h3>
|
88
|
+
<% @user_with_error.test = "b" %>
|
89
|
+
<%= bootstrap_form_with model: @user_with_error, scope: "user_e", url: "/" do |form| %>
|
90
|
+
<%= form.collection_radio_buttons :test, [["a", "Label A"], ["b", "Label B"]], :first, :second %>
|
91
|
+
<%= form.collection_check_boxes :test, [["e", "Label E"], ["f", "Label F"]], :first, :second, bootstrap: {help: "help text"} %>
|
92
|
+
<%= form.collection_radio_buttons :test, ["u", "v", "w"], :to_s, :to_s, bootstrap: {inline: true, label: {text: "Custom Label"}} %>
|
93
|
+
<%= form.collection_check_boxes :test, ["x", "y", "z"], :to_s, :to_s, bootstrap: {inline: true, help: "help text", label: {hide: true}} %>
|
94
|
+
<% end %>
|
95
|
+
</div>
|
96
|
+
</div>
|
72
97
|
|
73
|
-
<
|
98
|
+
<div class="row">
|
99
|
+
<div class="col-6">
|
100
|
+
<h3>Input Group</h3>
|
74
101
|
|
75
|
-
<%= bootstrap_form_with model: @
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
<% end %>
|
102
|
+
<%= bootstrap_form_with model: @user, scope: "user_f", url: "/" do |form| %>
|
103
|
+
<%= form.email_field :email, placeholder: "Enter Email", bootstrap: {prepend: "Prepend", append: "Append", help: "help text"} %>
|
104
|
+
<% prepend_button = capture do %>
|
105
|
+
<button class="btn btn-success">Go</button>
|
106
|
+
<% end %>
|
107
|
+
<% append_button = capture do %>
|
108
|
+
<button class="btn btn-danger">Stop</button>
|
109
|
+
<% end %>
|
110
|
+
<%= form.email_field :email, placeholder: "Enter Email", bootstrap: {label: {hide: true}, prepend: {html: prepend_button}, append: {html: append_button}} %>
|
111
|
+
<% end %>
|
112
|
+
</div>
|
113
|
+
<div class="col-6">
|
114
|
+
<h3>With Errors</h3>
|
115
|
+
|
116
|
+
<%= bootstrap_form_with model: @user_with_error, scope: "user_g", url: "/" do |form| %>
|
117
|
+
<%= form.email_field :email, placeholder: "Enter Email", bootstrap: {prepend: "Prepend", append: "Append", help: "help text"} %>
|
118
|
+
<% prepend_button = capture do %>
|
119
|
+
<button class="btn btn-success">Go</button>
|
120
|
+
<% end %>
|
121
|
+
<% append_button = capture do %>
|
122
|
+
<button class="btn btn-danger">Stop</button>
|
123
|
+
<% end %>
|
124
|
+
<%= form.email_field :email, placeholder: "Enter Email", bootstrap: {label: {hide: true}, prepend: {html: prepend_button}, append: {html: append_button}} %>
|
125
|
+
<% end %>
|
126
|
+
<div>
|
127
|
+
</div>
|
data/demo/db/schema.rb
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|