Skip to content

Commit c0f00f9

Browse files
committed
Don't assume eveybody loves *. Only define the CSS class 'required' with the label and
leave the actual CSS definition up to the user.
1 parent 20eaf3d commit c0f00f9

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,23 @@ class, which keeps your labels accessible to those using screen readers.
133133
```erb
134134
<%= f.text_area :comment, hide_label: :true, placeholder: "Leave a comment..." %>
135135
```
136+
#### Required Fields
136137

137-
Required fields are automatically annotated with a "required" CSS class. The
138-
required class results in an asterix being added to the end of the label name.
139-
The field is determined to be required if the associated model attribute is
140-
configured with a presence validator
141-
(ActiveRecord::Validations::PresenceValidator).
138+
A label that is associated with a required field is automatically annotated with
139+
a `required` CSS class. You are free to add any appropriate CSS to style
140+
required fields as desired. One example would be to automatically add an
141+
asterisk to the end of the label:
142+
143+
```css
144+
label.required:after {
145+
content:" *";
146+
}
147+
```
148+
149+
The label `required` class is determined based on the definition of a presence
150+
validator with the associated model attribute. Presently this is one of:
151+
ActiveRecord::Validations::PresenceValidator or
152+
ActiveModel::Validations::PresenceValidator.
142153

143154
### Help Text
144155

app/assets/stylesheets/rails_bootstrap_forms.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,3 @@
88
.rails-bootstrap-forms-error-summary {
99
margin-top: 10px;
1010
}
11-
12-
label.required:after {
13-
content:" *";
14-
}

0 commit comments

Comments
 (0)