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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7189d09fd03c20905ee8e5a3d6cdfa81585f88670186ff34f13abf221402e4f0
4
- data.tar.gz: 6158e79226dddbfc05bf62930d740da938c7aa76db5a8823647138299e8e8a53
3
+ metadata.gz: e259644ff4ca92f7c1ad851f4b49405baf41f12db6f2352d2bc86742d102e678
4
+ data.tar.gz: 5ff70b67fc490005cb33e0c0d0c0211a3181e67470c8aa22266af299a27c0f0c
5
5
  SHA512:
6
- metadata.gz: b948ce024eecd7b758eb7bac1a52ebaba4d5f492a01edd22856a29c4445d011c2ffe51e112479952a7fcdff98c1ef28ba44a5296d6ad56930c17d7778a1af7d7
7
- data.tar.gz: 231c0dd82d743e5040959b8d92cc0ce17b6440d203a5c69625c239eca7961a28563b22434e7742153863d2b01ad50902d0430e88c2b3917a9c7e8cb7a087c10b
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
@@ -12,3 +12,6 @@ branches:
12
12
  before_install:
13
13
  - gem update --system
14
14
  - gem install bundler --no-document
15
+ script:
16
+ - bundle exec rake test
17
+ - bundle exec rubocop
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 "minitest"
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 |f| %>
33
- <%= f.email_field :email %>
34
- <%= f.password_field :password %>
35
- <%= f.check_box :remember_me %>
36
- <%= f.submit "Log In" %>
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: {inline: true} %>
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
- #### Horizontal Form
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
- By default form is rendered as a stack. Labels are above inputs, and inputs
159
- take up 100% of the width. You can change form layout to `horizontal` to put
160
- labels and corresponding inputs side by side:
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: {layout: :horizontal} do |form| %>
164
- <%= form.text_field :email %>
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
- There are options that control column width and label alignment. Here's how it
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
- bootstrap_options = {
174
- layout: "horizontal",
175
- label_col_class: "col-sm-2",
176
- control_col_class: "col-sm-10",
177
- label_align_class: "text-sm-right"
178
- }
179
- %>
180
- <%= bootstrap_form_with model: @user, bootstrap: bootstrap_options do |form| %>
181
- <%= form.text_field :email %>
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 'bundler/setup'
2
+ require "bundler/setup"
3
3
  rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
5
  end
6
6
 
7
- require 'rdoc/task'
7
+ require "rdoc/task"
8
8
 
9
9
  RDoc::Task.new(:rdoc) do |rdoc|
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')
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 'bundler/gem_tasks'
17
+ require "bundler/gem_tasks"
18
18
 
19
- require 'rake/testtask'
19
+ require "rake/testtask"
20
20
 
21
21
  Rake::TestTask.new(:test) do |t|
22
- t.libs << 'test'
23
- t.pattern = 'test/**/*_test.rb'
22
+ t.libs << "test"
23
+ t.pattern = "test/**/*_test.rb"
24
24
  t.verbose = false
25
25
  end
26
26
 
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("../lib", __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  require "bootstrap_form/version"
@@ -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(:email)
8
- @user_with_error.errors.add(:terms)
9
- @user_with_error.errors.add(:test)
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 :email, placeholder: "Enter Email", bootstrap: {label: {text: "Email address"}, help: "We'll never share your email with anyone else"} %>
5
- <%= form.email_field :email, bootstrap: {prepend: "Prepend", append: "Append"} %>
6
- <%= form.check_box :terms, bootstrap: {help: "You better check this"} %>
7
- <%= form.collection_radio_buttons :test, ["1", "2", "3"], :to_s, :to_s, bootstrap: {help: "help text"} %>
8
- <%= form.text_field :test, bootstrap: {label: {hide: true}} %>
9
- <%= form.collection_check_boxes :test, ["11", "22", "33"], :to_s, :to_s, bootstrap: {help: "help text", inline: true, label: {hide: true}} %>
10
- <%= form.form_group bootstrap: {label: {text: "Lorem", class: "lorem pt-0"}} do %>
11
- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
12
- tempor incididunt ut labore et dolore magna aliqua.
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>Inline Form</h3>
16
+ <h3>Horizontal Form With Errors</h3>
20
17
 
21
- <%= bootstrap_form_with model: @user, url: "/", bootstrap: {layout: :inline} do |form| %>
22
- <%= form.email_field :email, placeholder: "Enter Email" %>
23
- <%= form.password_field :password, placeholder: "Password", bootstrap: {label: {hide: true}, prepend: "???", append: "???"} %>
24
- <%= form.check_box :terms %>
25
- <%= form.form_group do %>
26
- Lorem
27
- <% end %>
28
- <%= form.primary "Submit" do %>
29
- <a href="/" class="btn btn-link">Cancel</a>
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>Simple Form</h3>
31
+ <h3>Inline Form</h3>
34
32
 
35
- <%= bootstrap_form_with model: @user, url: "/" do |form| %>
36
- <%= form.email_field :email, placeholder: "Enter Email", bootstrap: {label: {text: "Email address"}, help: "We'll never share your email with anyone else"} %>
37
- <%= form.password_field :password, placeholder: "Password"%>
38
- <%= form.select :select_value, ["option A", "option B"] %>
39
- <%= form.text_area :test, bootstrap: {label: {text: "Text Area"}} %>
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
- <h3>Checkboxes and Radio buttons</h3>
40
+ <div class="row">
41
+ <div class="col-6">
42
+ <h3>Vertical Form</h3>
51
43
 
52
- <% @user.test = "c" %>
53
- <%= bootstrap_form_with model: @user, url: "/" do |form| %>
54
- <%= form.collection_radio_buttons :test, [["a", "Label A"], ["b", "Label B"]], :first, :second %>
55
- <%= form.collection_check_boxes :test, [["e", "Label E"], ["f", "Label F"]], :first, :second, bootstrap: {help: "help text"} %>
56
- <%= form.collection_radio_buttons :test, ["u", "v", "w"], :to_s, :to_s, bootstrap: {inline: true, label: {text: "Custom Label"}} %>
57
- <%= form.collection_check_boxes :test, ["x", "y", "z"], :to_s, :to_s, bootstrap: {inline: true, help: "help text", label: {hide: true}} %>
58
- <% end %>
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
- <h3>Input Group</h3>
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
- <%= bootstrap_form_with model: @user, url: "/" do |form| %>
63
- <%= form.email_field :email, placeholder: "Enter Email", bootstrap: {prepend: "Prepend", append: "Append"} %>
64
- <% prepend_button = capture do %>
65
- <button class="btn btn-success">Go</button>
66
- <% end %>
67
- <% append_button = capture do %>
68
- <button class="btn btn-danger">Stop</button>
69
- <% end %>
70
- <%= form.email_field :email, placeholder: "Enter Email", bootstrap: {label: {hide: true}, prepend: {html: prepend_button}, append: {html: append_button}} %>
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
- <h3>Horizontal Form With Errors</h3>
98
+ <div class="row">
99
+ <div class="col-6">
100
+ <h3>Input Group</h3>
74
101
 
75
- <%= bootstrap_form_with model: @user_with_error, url: "/", bootstrap: {layout: :horizontal} do |form| %>
76
- <%= form.email_field :email, placeholder: "Enter Email", bootstrap: {label: {text: "Email address"}, help: "We'll never share your email with anyone else"} %>
77
- <%= form.email_field :email, placeholder: "Enter Email", bootstrap: {help: "Help me!", prepend: "Prepend", append: "Append"} %>
78
- <%= form.check_box :terms, bootstrap: {help: "help text"}%>
79
- <%= form.collection_radio_buttons :test, ["a", "b", "c"], :to_s, :to_s, bootstrap: {help: "help text"} %>
80
- <%= form.collection_check_boxes :test, ["x", "y", "z"], :to_s, :to_s, bootstrap: {inline: true, help: "help text"} %>
81
- <%= form.submit %>
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
@@ -5,6 +5,9 @@ ActiveRecord::Schema.define(version: 1) do
5
5
  t.string :password
6
6
  t.boolean :terms, default: false
7
7
  t.string :test
8
+ t.string :bio
9
+ t.string :color
10
+ t.string :locale
8
11
  t.timestamps
9
12
  end
10
13
 
Binary file
Binary file
Binary file