Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ This generates:
</div>
</div>
</div>

<div class="mb-3 row">
<div class="col-sm-10 offset-sm-2">
<input class="btn btn-secondary" data-disable-with="Create User" name="commit" type="submit" value="Create User">
Expand Down Expand Up @@ -1561,6 +1561,53 @@ This generates:
</div>
```

### Required belongs_to associations

Adding a form control for a `belongs_to` field will automatically pick up the associated presence validator.

![Example 51](demo/doc/screenshots/bootstrap/readme/51_example.png "Example 51")
```erb
<%= bootstrap_form_for(@address, url: '/address') do |f| %>
<%= f.collection_select :user_id, @users, :id, :email, include_blank: "Select a value" %>
<%= f.text_field :street %>
<%= f.text_field :city %>
<%= f.text_field :state %>
<%= f.text_field :zip_code %>
<%= f.submit "Save" %>
<% end %>
```

Generated HTML:

```html
<form accept-charset="UTF-8" action="/address" class="new_address" id="new_address_1" method="post">
<div class="mb-3">
<label class="form-label required" for="address_user_id">User</label>
<select class="form-select" id="address_user_id" name="address[user_id]">
<option value="">Select a value</option>
<option value="">steve@example.com</option>
</select>
</div>
<div class="mb-3">
<label class="form-label" for="address_street">Street</label>
<input class="form-control" id="address_street" name="address[street]" type="text" value="Foo">
</div>
<div class="mb-3">
<label class="form-label" for="address_city">City</label>
<input class="form-control" id="address_city" name="address[city]" type="text">
</div>
<div class="mb-3">
<label class="form-label" for="address_state">State</label>
<input class="form-control" id="address_state" name="address[state]" type="text">
</div>
<div class="mb-3">
<label class="form-label" for="address_zip_code">Zip code</label>
<input class="form-control" id="address_zip_code" name="address[zip_code]" type="text">
</div>
<input class="btn btn-secondary" data-disable-with="Save" name="commit" type="submit" value="Save">
</form>
```

## Internationalization

bootstrap_form follows standard rails conventions so it's i18n-ready. See more
Expand Down
2 changes: 1 addition & 1 deletion demo/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ gem "sassc-rails"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[mri mingw x64_mingw]
# gem "debug", platforms: %i[mri mingw x64_mingw]
end

group :development do
Expand Down
176 changes: 85 additions & 91 deletions demo/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.2.4)
actionpack (= 7.0.2.4)
activesupport (= 7.0.2.4)
actioncable (7.0.3.1)
actionpack (= 7.0.3.1)
activesupport (= 7.0.3.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.2.4)
actionpack (= 7.0.2.4)
activejob (= 7.0.2.4)
activerecord (= 7.0.2.4)
activestorage (= 7.0.2.4)
activesupport (= 7.0.2.4)
actionmailbox (7.0.3.1)
actionpack (= 7.0.3.1)
activejob (= 7.0.3.1)
activerecord (= 7.0.3.1)
activestorage (= 7.0.3.1)
activesupport (= 7.0.3.1)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.2.4)
actionpack (= 7.0.2.4)
actionview (= 7.0.2.4)
activejob (= 7.0.2.4)
activesupport (= 7.0.2.4)
actionmailer (7.0.3.1)
actionpack (= 7.0.3.1)
actionview (= 7.0.3.1)
activejob (= 7.0.3.1)
activesupport (= 7.0.3.1)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.2.4)
actionview (= 7.0.2.4)
activesupport (= 7.0.2.4)
actionpack (7.0.3.1)
actionview (= 7.0.3.1)
activesupport (= 7.0.3.1)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.2.4)
actionpack (= 7.0.2.4)
activerecord (= 7.0.2.4)
activestorage (= 7.0.2.4)
activesupport (= 7.0.2.4)
actiontext (7.0.3.1)
actionpack (= 7.0.3.1)
activerecord (= 7.0.3.1)
activestorage (= 7.0.3.1)
activesupport (= 7.0.3.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.2.4)
activesupport (= 7.0.2.4)
actionview (7.0.3.1)
activesupport (= 7.0.3.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.2.4)
activesupport (= 7.0.2.4)
activejob (7.0.3.1)
activesupport (= 7.0.3.1)
globalid (>= 0.3.6)
activemodel (7.0.2.4)
activesupport (= 7.0.2.4)
activerecord (7.0.2.4)
activemodel (= 7.0.2.4)
activesupport (= 7.0.2.4)
activestorage (7.0.2.4)
actionpack (= 7.0.2.4)
activejob (= 7.0.2.4)
activerecord (= 7.0.2.4)
activesupport (= 7.0.2.4)
activemodel (7.0.3.1)
activesupport (= 7.0.3.1)
activerecord (7.0.3.1)
activemodel (= 7.0.3.1)
activesupport (= 7.0.3.1)
activestorage (7.0.3.1)
actionpack (= 7.0.3.1)
activejob (= 7.0.3.1)
activerecord (= 7.0.3.1)
activesupport (= 7.0.3.1)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.2.4)
activesupport (7.0.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
bindex (0.8.1)
bootsnap (1.11.1)
bootsnap (1.13.0)
msgpack (~> 1.2)
bootstrap_form (5.0.0)
bootstrap_form (5.1.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
builder (3.2.4)
capybara (3.36.0)
capybara (3.37.1)
addressable
matrix
mini_mime (>= 0.1.3)
Expand All @@ -84,36 +84,30 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
capybara-screenshot-diff (1.6.1)
capybara-screenshot-diff (1.6.3)
actionpack (>= 4.2, < 8)
capybara (>= 2, < 4)
chunky_png (~> 1.3)
childprocess (4.1.0)
chunky_png (1.4.0)
concurrent-ruby (1.1.10)
crass (1.0.6)
cssbundling-rails (1.1.0)
cssbundling-rails (1.1.1)
railties (>= 6.0.0)
debug (1.5.0)
irb (>= 1.3.6)
reline (>= 0.2.7)
digest (3.1.0)
erubi (1.10.0)
erubi (1.11.0)
ffi (1.15.5)
globalid (1.0.0)
activesupport (>= 5.0)
htmlbeautifier (1.4.2)
i18n (1.10.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
io-console (0.5.11)
irb (1.4.1)
reline (>= 0.3.0)
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jsbundling-rails (1.0.2)
jsbundling-rails (1.0.3)
railties (>= 6.0.0)
loofah (2.16.0)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
Expand All @@ -122,8 +116,8 @@ GEM
matrix (0.4.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.15.0)
msgpack (1.5.1)
minitest (5.16.2)
msgpack (1.5.4)
net-imap (0.2.3)
digest
net-protocol
Expand All @@ -139,47 +133,45 @@ GEM
net-protocol
timeout
nio4r (2.5.8)
nokogiri (1.13.4-x86_64-darwin)
nokogiri (1.13.8-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.4-x86_64-linux)
nokogiri (1.13.8-x86_64-linux)
racc (~> 1.4)
public_suffix (4.0.7)
puma (5.6.4)
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (7.0.2.4)
actioncable (= 7.0.2.4)
actionmailbox (= 7.0.2.4)
actionmailer (= 7.0.2.4)
actionpack (= 7.0.2.4)
actiontext (= 7.0.2.4)
actionview (= 7.0.2.4)
activejob (= 7.0.2.4)
activemodel (= 7.0.2.4)
activerecord (= 7.0.2.4)
activestorage (= 7.0.2.4)
activesupport (= 7.0.2.4)
rack (2.2.4)
rack-test (2.0.2)
rack (>= 1.3)
rails (7.0.3.1)
actioncable (= 7.0.3.1)
actionmailbox (= 7.0.3.1)
actionmailer (= 7.0.3.1)
actionpack (= 7.0.3.1)
actiontext (= 7.0.3.1)
actionview (= 7.0.3.1)
activejob (= 7.0.3.1)
activemodel (= 7.0.3.1)
activerecord (= 7.0.3.1)
activestorage (= 7.0.3.1)
activesupport (= 7.0.3.1)
bundler (>= 1.15.0)
railties (= 7.0.2.4)
railties (= 7.0.3.1)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
railties (7.0.2.4)
actionpack (= 7.0.2.4)
activesupport (= 7.0.2.4)
railties (7.0.3.1)
actionpack (= 7.0.3.1)
activesupport (= 7.0.3.1)
method_source
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rake (13.0.6)
regexp_parser (2.3.1)
reline (0.3.1)
io-console (~> 0.5)
regexp_parser (2.5.0)
rexml (3.2.5)
rubyzip (2.3.2)
sassc (2.4.0)
Expand All @@ -190,28 +182,30 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
selenium-webdriver (4.1.0)
selenium-webdriver (4.4.0)
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2)
sprockets (4.0.3)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sprockets (4.1.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
stimulus-rails (1.0.4)
sqlite3 (1.4.4)
stimulus-rails (1.1.0)
railties (>= 6.0.0)
strscan (3.0.1)
strscan (3.0.4)
thor (1.2.1)
tilt (2.0.10)
timeout (0.2.0)
turbo-rails (1.0.1)
tilt (2.0.11)
timeout (0.3.0)
turbo-rails (1.1.1)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.4)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
web-console (4.2.0)
actionview (>= 6.0.0)
Expand All @@ -222,12 +216,13 @@ GEM
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
websocket (1.2.9)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.5.4)
zeitwerk (2.6.0)

PLATFORMS
x86_64-darwin-21
Expand All @@ -238,7 +233,6 @@ DEPENDENCIES
bootstrap_form (~> 5.0)
capybara-screenshot-diff
cssbundling-rails
debug
htmlbeautifier
jbuilder
jsbundling-rails
Expand Down
4 changes: 4 additions & 0 deletions demo/app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
// @import "actiontext";

label.required:after {
content:" *";
}
Loading