comfy_bootstrap_form 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -2
  3. data/.travis.yml +2 -0
  4. data/Gemfile +3 -2
  5. data/LICENSE.md +1 -1
  6. data/README.md +32 -9
  7. data/bootstrap_form.gemspec +6 -3
  8. data/lib/bootstrap_form/version.rb +1 -1
  9. data/lib/bootstrap_form/view_helper.rb +30 -9
  10. metadata +5 -60
  11. data/demo/README.md +0 -18
  12. data/demo/Rakefile +0 -6
  13. data/demo/app/controllers/application_controller.rb +0 -2
  14. data/demo/app/controllers/bootstrap_controller.rb +0 -18
  15. data/demo/app/models/application_record.rb +0 -3
  16. data/demo/app/models/user.rb +0 -3
  17. data/demo/app/views/bootstrap/form.html.erb +0 -127
  18. data/demo/app/views/layouts/application.html.erb +0 -43
  19. data/demo/bin/bundle +0 -3
  20. data/demo/bin/rails +0 -4
  21. data/demo/bin/rake +0 -4
  22. data/demo/bin/setup +0 -36
  23. data/demo/bin/update +0 -31
  24. data/demo/bin/yarn +0 -11
  25. data/demo/config/application.rb +0 -24
  26. data/demo/config/boot.rb +0 -5
  27. data/demo/config/database.yml +0 -21
  28. data/demo/config/environment.rb +0 -5
  29. data/demo/config/environments/development.rb +0 -60
  30. data/demo/config/environments/test.rb +0 -48
  31. data/demo/config/initializers/application_controller_renderer.rb +0 -8
  32. data/demo/config/initializers/assets.rb +0 -14
  33. data/demo/config/initializers/backtrace_silencers.rb +0 -7
  34. data/demo/config/initializers/cookies_serializer.rb +0 -5
  35. data/demo/config/initializers/filter_parameter_logging.rb +0 -4
  36. data/demo/config/initializers/inflections.rb +0 -16
  37. data/demo/config/initializers/mime_types.rb +0 -4
  38. data/demo/config/initializers/wrap_parameters.rb +0 -14
  39. data/demo/config/locales/en.yml +0 -33
  40. data/demo/config/puma.rb +0 -56
  41. data/demo/config/routes.rb +0 -5
  42. data/demo/config/spring.rb +0 -6
  43. data/demo/config/storage.yml +0 -35
  44. data/demo/config.ru +0 -5
  45. data/demo/db/schema.rb +0 -14
  46. data/demo/form_preview_horizontal.png +0 -0
  47. data/demo/form_preview_horizontal_with_errors.png +0 -0
  48. data/demo/form_preview_inline.png +0 -0
  49. data/demo/form_preview_vertical.png +0 -0
  50. data/demo/log/.keep +0 -0
  51. data/demo/package.json +0 -5
  52. data/demo/public/favicon.ico +0 -0
  53. data/test/bootstrap_form/bootstrap_options_test.rb +0 -114
  54. data/test/bootstrap_form/fields_test.rb +0 -304
  55. data/test/bootstrap_form/fields_with_errors_test.rb +0 -111
  56. data/test/bootstrap_form/form_builder_test.rb +0 -17
  57. data/test/bootstrap_form/horizontal_form_test.rb +0 -160
  58. data/test/bootstrap_form/inline_form_test.rb +0 -68
  59. data/test/bootstrap_form/input_group_test.rb +0 -56
  60. data/test/bootstrap_form/radios_and_checkboxes_test.rb +0 -207
  61. data/test/bootstrap_form/submit_test.rb +0 -59
  62. data/test/bootstrap_form/view_helpers_test.rb +0 -99
  63. data/test/gemfiles/5.2.gemfile +0 -14
  64. data/test/test_helper.rb +0 -48
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e259644ff4ca92f7c1ad851f4b49405baf41f12db6f2352d2bc86742d102e678
4
- data.tar.gz: 5ff70b67fc490005cb33e0c0d0c0211a3181e67470c8aa22266af299a27c0f0c
3
+ metadata.gz: e1131134a470480c0db98c57088a09d3dc5875cdde69e2886c4ad58e56f85982
4
+ data.tar.gz: eb630d1a2474b38262f778ec6a77dcb6adcfb359f15ac11064e32aa164efbd26
5
5
  SHA512:
6
- metadata.gz: 214fbf0f8c2003616dd75707c156a4da91bb4d740a186fd7436a980eddc26fde7f0067c7c5e8fe2890451ee5f8005079c89d5ed22ea805b6e4e55a8fbbbf2c64
7
- data.tar.gz: d00c03f8af63d13203335322dbe2143100e5bdf0188069d517a8acf30be5861f69fbdefbd6367a52c31e6af8b808454a5dcdcdecfc0535c1b260512e32d759c5
6
+ metadata.gz: 3159663372d2ce7266d3145ade1a927c7195e99df1954c4a535bfd402ffeaf2155df31277887d09dff6b561b3167226f7baab64605661e7d8a09950f12c65647
7
+ data.tar.gz: de46cca64ea6c26c322336d544a6d4ac0c719067ae64d0b5d3dcbd77acff0570a1aa2440d343b0f87ba38abf611e7ea98c7d14cc3aa442a09b2444e880ef9cdc
data/.rubocop.yml CHANGED
@@ -1,5 +1,3 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
1
  AllCops:
4
2
  TargetRubyVersion: 2.2
5
3
  Exclude:
data/.travis.yml CHANGED
@@ -5,6 +5,8 @@ rvm:
5
5
  - 2.4.3
6
6
  - 2.5.0
7
7
  gemfile:
8
+ - test/gemfiles/5.0.gemfile
9
+ - test/gemfiles/5.1.gemfile
8
10
  - test/gemfiles/5.2.gemfile
9
11
  branches:
10
12
  only:
data/Gemfile CHANGED
@@ -3,16 +3,17 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  # Uncomment and change rails version for testing purposes
6
- # gem "rails", "~> 5.2.0.beta2"
6
+ # gem "rails", "~> 5.1.0"
7
7
 
8
8
  group :development do
9
- gem "rubocop", "~> 0.51.0", require: false
9
+ gem "rubocop", require: false
10
10
  end
11
11
 
12
12
  group :test do
13
13
  gem "coveralls", require: false
14
14
  gem "diffy"
15
15
  gem "equivalent-xml"
16
+ # gem "minitest", "~> 5.10.3"
16
17
  gem "minitest"
17
18
  gem "sqlite3"
18
19
  end
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2012-2018 Oleg Khabarov, Stephen Potenza <potenza@gmail.com>
1
+ Copyright 2018 Oleg Khabarov, Stephen Potenza
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  ## Requirements
15
15
 
16
- - Rails 5.2+
16
+ - Rails 5.0+
17
17
  - Bootstrap 4.0.0+
18
18
 
19
19
  ## Installation
@@ -68,6 +68,32 @@ Feel free to take a look at the [Demo App](/demo) to see how everything renders.
68
68
  Specifically see [form.html.erb](/demo/app/views/bootstrap/form.html.erb) template
69
69
  for all kinds of different form configurations you can have.
70
70
 
71
+ ## Form helpers
72
+
73
+ #### boostrap_form_with
74
+
75
+ Wrapper around `form_with` helper that's available in Rails 5.1 and above.
76
+ Here's an example:
77
+
78
+ ```erb
79
+ <%= bootstrap_form_with model: @person, scope: :user do |form| %>
80
+ <%= form.email_field :email %>
81
+ <%= form.submit %>
82
+ <% end %>
83
+ ```
84
+
85
+ #### bootstrap_form_for
86
+
87
+ Wrapper around `form_for` helper that's available in all Rails 5 versions.
88
+ Here's an example:
89
+
90
+ ```erb
91
+ <%= bootstrap_form_with @person, as: :user do |form| %>
92
+ <%= form.email_field :email %>
93
+ <%= form.submit %>
94
+ <% end %>
95
+ ```
96
+
71
97
  ## Supported form field helpers
72
98
 
73
99
  This gem wraps most of the default form field helpers. Here's the current list:
@@ -262,14 +288,11 @@ If you want to use something like a button, or other html content do this:
262
288
 
263
289
  ### Gotchas
264
290
 
265
- For inline radio buttons and check boxes you need to add custom css for error
266
- messages show up (see: https://github.com/twbs/bootstrap/issues/25540):
267
-
268
- ```css
269
- .invalid-feeback {
270
- display: block
271
- }
272
- ```
291
+ - In Rails 5.1 `form_with` does not generate ids for inputs. If you want them
292
+ you'll need to override this method: [actionview/lib/action_view/helpers/form_helper.rb#L745](https://github.com/rails/rails/blob/bdc581616b760d1e2be3795c6f0f3ab4b1e125a5/actionview/lib/action_view/helpers/form_helper.rb#L745)
293
+ - For inline radio buttons and check boxes you need to add custom css for error
294
+ messages show up. See: [twbs/bootstrap/issues/25540](https://github.com/twbs/bootstrap/issues/25540)
295
+ For now adding `.invalid-feeback { display: block }` will work.
273
296
 
274
297
  ## Screenshots
275
298
 
@@ -6,7 +6,7 @@ require "bootstrap_form/version"
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "comfy_bootstrap_form"
8
8
  s.version = BootstrapForm::VERSION
9
- s.authors = ["Oleg Khabarov", "Stephen Potenza"]
9
+ s.authors = ["Oleg Khabarov"]
10
10
  s.email = ["oleg@khabarov.ca"]
11
11
  s.homepage = "https://github.com/comfy/comfy-bootstrap-form"
12
12
  s.summary = "Rails form builder that makes it easy to style forms using "\
@@ -15,11 +15,14 @@ Gem::Specification.new do |s|
15
15
  "easy to create beautiful-looking forms using Bootstrap 4"
16
16
  s.license = "MIT"
17
17
 
18
- s.files = `git ls-files`.split("\n")
18
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|demo)/})
20
+ end
21
+
19
22
  s.bindir = "exe"
20
23
  s.require_paths = ["lib"]
21
24
 
22
25
  s.required_ruby_version = ">= 2.2.2"
23
26
 
24
- s.add_dependency "rails", ">= 5.2.rc1"
27
+ s.add_dependency "rails", ">= 5.0.0"
25
28
  end
@@ -1,5 +1,5 @@
1
1
  module BootstrapForm
2
2
 
3
- VERSION = "4.0.0".freeze
3
+ VERSION = "4.0.1".freeze
4
4
 
5
5
  end
@@ -3,26 +3,47 @@ module BootstrapForm
3
3
 
4
4
  # Wrapper for `form_with`. Passing in Bootstrap form builder.
5
5
  def bootstrap_form_with(**options, &block)
6
- supress_field_errors do
7
- css_classes = options.delete(:class) || ""
8
- bootstrap_options = options[:bootstrap] || {}
6
+ bootstrap_options = options[:bootstrap] || {}
9
7
 
10
- if bootstrap_options[:layout].to_s == "inline"
11
- css_classes << " form-inline"
12
- end
8
+ css_classes = options.delete(:class)
13
9
 
14
- form_options = options.reverse_merge(builder: BootstrapForm::FormBuilder)
15
- form_options.merge!(class: css_classes) unless css_classes.blank?
10
+ if bootstrap_options[:layout].to_s == "inline"
11
+ css_classes = [css_classes, "form-inline"].compact.join(" ")
12
+ end
13
+
14
+ form_options = options.reverse_merge(builder: BootstrapForm::FormBuilder)
15
+ form_options.merge!(class: css_classes) unless css_classes.blank?
16
+
17
+ supress_form_field_errors do
16
18
  form_with(**form_options, &block)
17
19
  end
18
20
  end
19
21
 
22
+ def bootstrap_form_for(record, options = {}, &block)
23
+ options[:html] ||= {}
24
+
25
+ bootstrap_options = options[:bootstrap] || {}
26
+
27
+ css_classes = options[:html].delete(:class)
28
+
29
+ if bootstrap_options[:layout].to_s == "inline"
30
+ css_classes = [css_classes, "form-inline"].compact.join(" ")
31
+ end
32
+
33
+ options.reverse_merge!(builder: BootstrapForm::FormBuilder)
34
+ options[:html].merge!(class: css_classes) unless css_classes.blank?
35
+
36
+ supress_form_field_errors do
37
+ form_for(record, options, &block)
38
+ end
39
+ end
40
+
20
41
  private
21
42
 
22
43
  # By default, Rails will wrap form fields with extra html to indicate
23
44
  # inputs with errors. We need to handle this in the builder to render
24
45
  # Bootstrap specific markup. So we need to bypass this.
25
- def supress_field_errors
46
+ def supress_form_field_errors
26
47
  original_proc = ActionView::Base.field_error_proc
27
48
  ActionView::Base.field_error_proc = proc { |input, _instance| input }
28
49
  yield
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comfy_bootstrap_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Khabarov
8
- - Stephen Potenza
9
8
  autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2018-02-08 00:00:00.000000000 Z
11
+ date: 2018-02-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
@@ -17,14 +16,14 @@ dependencies:
17
16
  requirements:
18
17
  - - ">="
19
18
  - !ruby/object:Gem::Version
20
- version: 5.2.rc1
19
+ version: 5.0.0
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
24
  - - ">="
26
25
  - !ruby/object:Gem::Version
27
- version: 5.2.rc1
26
+ version: 5.0.0
28
27
  description: bootstrap_form is a rails form builder that makes it super easy to create
29
28
  beautiful-looking forms using Bootstrap 4
30
29
  email:
@@ -42,66 +41,12 @@ files:
42
41
  - README.md
43
42
  - Rakefile
44
43
  - bootstrap_form.gemspec
45
- - demo/README.md
46
- - demo/Rakefile
47
- - demo/app/controllers/application_controller.rb
48
- - demo/app/controllers/bootstrap_controller.rb
49
- - demo/app/models/application_record.rb
50
- - demo/app/models/user.rb
51
- - demo/app/views/bootstrap/form.html.erb
52
- - demo/app/views/layouts/application.html.erb
53
- - demo/bin/bundle
54
- - demo/bin/rails
55
- - demo/bin/rake
56
- - demo/bin/setup
57
- - demo/bin/update
58
- - demo/bin/yarn
59
- - demo/config.ru
60
- - demo/config/application.rb
61
- - demo/config/boot.rb
62
- - demo/config/database.yml
63
- - demo/config/environment.rb
64
- - demo/config/environments/development.rb
65
- - demo/config/environments/test.rb
66
- - demo/config/initializers/application_controller_renderer.rb
67
- - demo/config/initializers/assets.rb
68
- - demo/config/initializers/backtrace_silencers.rb
69
- - demo/config/initializers/cookies_serializer.rb
70
- - demo/config/initializers/filter_parameter_logging.rb
71
- - demo/config/initializers/inflections.rb
72
- - demo/config/initializers/mime_types.rb
73
- - demo/config/initializers/wrap_parameters.rb
74
- - demo/config/locales/en.yml
75
- - demo/config/puma.rb
76
- - demo/config/routes.rb
77
- - demo/config/spring.rb
78
- - demo/config/storage.yml
79
- - demo/db/schema.rb
80
- - demo/form_preview_horizontal.png
81
- - demo/form_preview_horizontal_with_errors.png
82
- - demo/form_preview_inline.png
83
- - demo/form_preview_vertical.png
84
- - demo/log/.keep
85
- - demo/package.json
86
- - demo/public/favicon.ico
87
44
  - lib/bootstrap_form.rb
88
45
  - lib/bootstrap_form/bootstrap_options.rb
89
46
  - lib/bootstrap_form/form_builder.rb
90
47
  - lib/bootstrap_form/version.rb
91
48
  - lib/bootstrap_form/view_helper.rb
92
49
  - lib/comfy_bootstrap_form.rb
93
- - test/bootstrap_form/bootstrap_options_test.rb
94
- - test/bootstrap_form/fields_test.rb
95
- - test/bootstrap_form/fields_with_errors_test.rb
96
- - test/bootstrap_form/form_builder_test.rb
97
- - test/bootstrap_form/horizontal_form_test.rb
98
- - test/bootstrap_form/inline_form_test.rb
99
- - test/bootstrap_form/input_group_test.rb
100
- - test/bootstrap_form/radios_and_checkboxes_test.rb
101
- - test/bootstrap_form/submit_test.rb
102
- - test/bootstrap_form/view_helpers_test.rb
103
- - test/gemfiles/5.2.gemfile
104
- - test/test_helper.rb
105
50
  homepage: https://github.com/comfy/comfy-bootstrap-form
106
51
  licenses:
107
52
  - MIT
@@ -122,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
67
  version: '0'
123
68
  requirements: []
124
69
  rubyforge_project:
125
- rubygems_version: 2.7.4
70
+ rubygems_version: 2.7.5
126
71
  signing_key:
127
72
  specification_version: 4
128
73
  summary: Rails form builder that makes it easy to style forms using Bootstrap 4
data/demo/README.md DELETED
@@ -1,18 +0,0 @@
1
- # DEMO APP (Rails 5.2)
2
-
3
- ### Usage
4
-
5
- - `rake db:schema:load`
6
- - `rails s`
7
- - Navigate to http://localhost:3000
8
- - Start changing stuff in [/demo/app/views/bootstrap/form.html.erb](/demo/app/views/bootstrap/form.html.erb)
9
-
10
- ### Following files were added or changed:
11
-
12
- - db/schema.rb
13
- - config/{application, routes, boot}.rb
14
- - config/environments/{development, test}.rb
15
- - app/models/user.rb
16
- - app/controllers/bootstrap_controller.rb
17
- - app/views/layouts/application.html.erb
18
- - app/views/bootstrap/form.html.erb
data/demo/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require_relative 'config/application'
5
-
6
- Rails.application.load_tasks
@@ -1,2 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- end
@@ -1,18 +0,0 @@
1
- class BootstrapController < ApplicationController
2
-
3
- def form
4
- @user = User.new(test: "Lorem ipsum")
5
-
6
- @user_with_error = User.new
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
-
16
- end
17
-
18
- end
@@ -1,3 +0,0 @@
1
- class ApplicationRecord < ActiveRecord::Base
2
- self.abstract_class = true
3
- end
@@ -1,3 +0,0 @@
1
- class User < ActiveRecord::Base
2
-
3
- end
@@ -1,127 +0,0 @@
1
- <h3>Horizontal Form</h3>
2
-
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>
13
- <% end %>
14
- <% end %>
15
-
16
- <h3>Horizontal Form With Errors</h3>
17
-
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>
28
- <% end %>
29
- <% end %>
30
-
31
- <h3>Inline Form</h3>
32
-
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" %>
38
- <% end %>
39
-
40
- <div class="row">
41
- <div class="col-6">
42
- <h3>Vertical Form</h3>
43
-
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
-
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>
74
-
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>
97
-
98
- <div class="row">
99
- <div class="col-6">
100
- <h3>Input Group</h3>
101
-
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>