-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Indent checkbox into second column for horizontal layout Align label with the top of the first check box in a collection in horizontal layout Vertically align check boxes and labels in inline layout. Allow overriding the label class, not just add more classes.
- Loading branch information
Showing
12 changed files
with
84 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,7 +258,7 @@ This generates: | |
|
||
```html | ||
<div class="mb-3"> | ||
<label class="form-label visually-hidden" for="user_comment">Comment</label> | ||
<label class="visually-hidden" for="user_comment">Comment</label> | ||
<textarea class="form-control" id="user_comment" name="user[comment]" placeholder="Leave a comment..."> | ||
</textarea> | ||
</div> | ||
|
@@ -275,7 +275,7 @@ This generates: | |
|
||
```html | ||
<div class="mb-3"> | ||
<label class="form-label custom-class required" for="user_email">Email</label> | ||
<label class="custom-class required" for="user_email">Email</label> | ||
<input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="text" value="[email protected]"> | ||
</div> | ||
``` | ||
|
@@ -291,7 +291,7 @@ This generates: | |
|
||
```html | ||
<div class="mb-3"> | ||
<label class="form-label visually-hidden required" for="user_email">Email</label> | ||
<label class="visually-hidden required" for="user_email">Email</label> | ||
<input aria-required="true" class="form-control" id="user_email" name="user[email]" placeholder="Email" required="required" type="text" value=""> | ||
</div> | ||
``` | ||
|
@@ -1049,17 +1049,19 @@ This generates: | |
```html | ||
<form accept-charset="UTF-8" action="/users" class="new_user row row-cols-auto g-3 align-items-center" id="new_user" method="post"> | ||
<div class="col"> | ||
<label class="form-label visually-hidden me-sm-2 required" for="user_email">Email</label> | ||
<label class="visually-hidden me-sm-2 required" for="user_email">Email</label> | ||
<input aria-required="true" class="form-control" id="user_email" name="user[email]" required="required" type="email" value="[email protected]"> | ||
</div> | ||
<div class="col"> | ||
<label class="form-label visually-hidden me-sm-2" for="user_password">Password</label> | ||
<label class="visually-hidden me-sm-2" for="user_password">Password</label> | ||
<input class="form-control" id="user_password" name="user[password]" type="password"> | ||
</div> | ||
<div class="form-check form-check-inline mb-3"> | ||
<input autocomplete="off" name="user[remember_me]" type="hidden" value="0"> | ||
<input class="form-check-input" id="user_remember_me" name="user[remember_me]" type="checkbox" value="1"> | ||
<label class="form-check-label" for="user_remember_me">Remember me</label> | ||
<div class="col"> | ||
<div class="form-check form-check-inline"> | ||
<input autocomplete="off" name="user[remember_me]" type="hidden" value="0"> | ||
<input class="form-check-input" id="user_remember_me" name="user[remember_me]" type="checkbox" value="1"> | ||
<label class="form-check-label" for="user_remember_me">Remember me</label> | ||
</div> | ||
</div> | ||
<div class="col"> | ||
<input class="btn btn-secondary" data-disable-with="Create User" name="commit" type="submit" value="Create User"> | ||
|
@@ -1096,9 +1098,7 @@ In the example below, the checkbox and submit button have been wrapped in a | |
<%= bootstrap_form_for(@user, layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10") do |f| %> | ||
<%= f.email_field :email %> | ||
<%= f.password_field :password %> | ||
<%= f.form_group do %> | ||
<%= f.check_box :remember_me %> | ||
<% end %> | ||
<%= f.check_box :remember_me %> | ||
<%= f.form_group do %> | ||
<%= f.submit %> | ||
<% end %> | ||
|
Binary file modified
BIN
+24 Bytes
(100%)
demo/doc/screenshots/bootstrap/index/00_horizontal_form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-5 Bytes
(100%)
demo/doc/screenshots/bootstrap/index/01_with_validation_error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ class BootstrapFormGroupTest < ActionView::TestCase | |
test "hiding a label" do | ||
expected = <<~HTML | ||
<div class="mb-3"> | ||
<label class="form-label visually-hidden required" for="user_email">Email</label> | ||
<label class="visually-hidden required" for="user_email">Email</label> | ||
<input aria-required="true" required="required" class="form-control" id="user_email" name="user[email]" type="text" value="[email protected]" /> | ||
</div> | ||
HTML | ||
|
@@ -38,7 +38,7 @@ class BootstrapFormGroupTest < ActionView::TestCase | |
test "adding a custom label class via the label_class parameter" do | ||
expected = <<~HTML | ||
<div class="mb-3"> | ||
<label class="form-label btn required" for="user_email">Email</label> | ||
<label class="btn required" for="user_email">Email</label> | ||
<input aria-required="true" required="required" class="form-control" id="user_email" name="user[email]" type="text" value="[email protected]" /> | ||
</div> | ||
HTML | ||
|
@@ -48,7 +48,7 @@ class BootstrapFormGroupTest < ActionView::TestCase | |
test "adding a custom label class via the html_options label hash" do | ||
expected = <<~HTML | ||
<div class="mb-3"> | ||
<label class="form-label btn required" for="user_email">Email</label> | ||
<label class="btn required" for="user_email">Email</label> | ||
<input aria-required="true" required="required" class="form-control" id="user_email" name="user[email]" type="text" value="[email protected]" /> | ||
</div> | ||
HTML | ||
|
@@ -58,7 +58,7 @@ class BootstrapFormGroupTest < ActionView::TestCase | |
test "adding a custom label and changing the label text via the html_options label hash" do | ||
expected = <<~HTML | ||
<div class="mb-3"> | ||
<label class="form-label btn required" for="user_email">Email Address</label> | ||
<label class="btn required" for="user_email">Email Address</label> | ||
<input aria-required="true" required="required" class="form-control" id="user_email" name="user[email]" type="text" value="[email protected]" /> | ||
</div> | ||
HTML | ||
|
@@ -109,7 +109,7 @@ class BootstrapFormGroupTest < ActionView::TestCase | |
test "label as placeholder" do | ||
expected = <<~HTML | ||
<div class="mb-3"> | ||
<label class="form-label visually-hidden required" for="user_email">Email</label> | ||
<label class="visually-hidden required" for="user_email">Email</label> | ||
<input aria-required="true" required="required" class="form-control" id="user_email" placeholder="Email" name="user[email]" type="text" value="[email protected]" /> | ||
</div> | ||
HTML | ||
|
@@ -379,7 +379,7 @@ class BootstrapFormGroupTest < ActionView::TestCase | |
|
||
expected = <<~HTML | ||
<div class="mb-3 row"> | ||
<label class="form-label foo col-form-label col-sm-2" for="bar">Custom Control</label> | ||
<label class="foo col-form-label col-sm-2" for="bar">Custom Control</label> | ||
<div class="col-sm-10"> | ||
<input class="form-control-plaintext" value="Bar"> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,13 +132,15 @@ class BootstrapFormTest < ActionView::TestCase | |
<label class="form-label me-sm-2 required" for="user_email">Email</label> | ||
<input aria-required="true" required="required" class="form-control" id="user_email" name="user[email]" type="email" value="[email protected]" /> | ||
</div> | ||
<div class="form-check form-check-inline mb-3"> | ||
<input #{autocomplete_attr} name="user[terms]" type="hidden" value="0" /> | ||
<input class="form-check-input" id="user_terms" name="user[terms]" type="checkbox" value="1" /> | ||
<label class="form-check-label" for="user_terms">I agree to the terms</label> | ||
<div class="col"> | ||
<div class="form-check form-check-inline"> | ||
<input #{autocomplete_attr} name="user[terms]" type="hidden" value="0" /> | ||
<input class="form-check-input" id="user_terms" name="user[terms]" type="checkbox" value="1" /> | ||
<label class="form-check-label" for="user_terms">I agree to the terms</label> | ||
</div> | ||
</div> | ||
<div class="col"> | ||
<label class="form-label me-sm-2" for="user_misc">Misc</label> | ||
<label class="form-check form-check-inline ps-0 me-sm-2" for="user_misc">Misc</label> | ||
<div class="form-check form-check-inline"> | ||
<input class="form-check-input" id="user_misc_1" name="user[misc]" type="radio" value="1" /> | ||
<label class="form-check-label" for="user_misc_1">Foo</label> | ||
|
@@ -179,13 +181,17 @@ class BootstrapFormTest < ActionView::TestCase | |
<input aria-required="true" required="required" class="form-control" id="user_email" name="user[email]" type="email" value="[email protected]" /> | ||
</div> | ||
</div> | ||
<div class="form-check"> | ||
<input #{autocomplete_attr} name="user[terms]" type="hidden" value="0" /> | ||
<input class="form-check-input" id="user_terms" name="user[terms]" type="checkbox" value="1" /> | ||
<label class="form-check-label" for="user_terms">I agree to the terms</label> | ||
<div class="mb-3 row"> | ||
<div class="col-sm-10 offset-sm-2"> | ||
<div class="form-check"> | ||
<input #{autocomplete_attr} name="user[terms]" type="hidden" value="0" /> | ||
<input class="form-check-input" id="user_terms" name="user[terms]" type="checkbox" value="1" /> | ||
<label class="form-check-label" for="user_terms">I agree to the terms</label> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="mb-3 row"> | ||
<label class="form-label col-form-label col-sm-2" for="user_misc">Misc</label> | ||
<label class="col-form-label pt-0 col-form-label col-sm-2" for="user_misc">Misc</label> | ||
<div class="col-sm-10"> | ||
<div class="form-check"> | ||
<input class="form-check-input" id="user_misc_1" name="user[misc]" type="radio" value="1" /> | ||
|
@@ -228,13 +234,17 @@ class BootstrapFormTest < ActionView::TestCase | |
<label class="form-label required" for="user_email">Email</label> | ||
<input aria-required="true" required="required" class="form-control" id="user_email" name="user[email]" type="email" value="[email protected]" /> | ||
</div> | ||
<div class="form-check"> | ||
<input #{autocomplete_attr} name="user[terms]" type="hidden" value="0" /> | ||
<input class="form-check-input" id="user_terms" name="user[terms]" type="checkbox" value="1" /> | ||
<label class="form-check-label" for="user_terms">I agree to the terms</label> | ||
<div class="mb-3 row"> | ||
<div class="col-sm-10 offset-sm-2"> | ||
<div class="form-check"> | ||
<input #{autocomplete_attr} name="user[terms]" type="hidden" value="0" /> | ||
<input class="form-check-input" id="user_terms" name="user[terms]" type="checkbox" value="1" /> | ||
<label class="form-check-label" for="user_terms">I agree to the terms</label> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="mb-3"> | ||
<label class="form-label" for="user_misc">Misc</label> | ||
<label class="col-form-label pt-0" for="user_misc">Misc</label> | ||
<div class="form-check"> | ||
<input class="form-check-input" id="user_misc_1" name="user[misc]" type="radio" value="1" /> | ||
<label class="form-check-label" for="user_misc_1">Foo</label> | ||
|
@@ -274,13 +284,17 @@ class BootstrapFormTest < ActionView::TestCase | |
<label class="form-label me-sm-2 required" for="user_email">Email</label> | ||
<input aria-required="true" required="required" class="form-control" id="user_email" name="user[email]" type="email" value="[email protected]" /> | ||
</div> | ||
<div class="form-check form-check-inline"> | ||
<input #{autocomplete_attr} name="user[terms]" type="hidden" value="0" /> | ||
<input class="form-check-input" id="user_terms" name="user[terms]" type="checkbox" value="1" /> | ||
<label class="form-check-label" for="user_terms">I agree to the terms</label> | ||
<div class="mb-3 row"> | ||
<div class="col-sm-10 offset-sm-2"> | ||
<div class="form-check form-check-inline"> | ||
<input #{autocomplete_attr} name="user[terms]" type="hidden" value="0" /> | ||
<input class="form-check-input" id="user_terms" name="user[terms]" type="checkbox" value="1" /> | ||
<label class="form-check-label" for="user_terms">I agree to the terms</label> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="mb-3 col-auto g-3"> | ||
<label class="form-label me-sm-2" for="user_misc">Misc</label> | ||
<label class="col-form-label pt-0 me-sm-2" for="user_misc">Misc</label> | ||
<div class="form-check form-check-inline"> | ||
<input class="form-check-input" id="user_misc_1" name="user[misc]" type="radio" value="1" /> | ||
<label class="form-check-label" for="user_misc_1">Foo</label> | ||
|