16
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails5.1 + Bootstrap4でfield_with_errors

Posted at

field_with_errorsクラスとは?

Railsのバリデーションでエラーになった箇所に付与されるクラスの事です。
Workman.png

Bootstrap3

  • field_with_errorsクラスに対して Bootstrap3の .has-error をextendすることで入力欄が赤枠で表示されていた。
application.scss
.field_with_errors {
  @extend .has-error;
}

Bootstrap4

  • .has-error が無くなっているのでextendできない。
  • 代わりに input タグに対して .is-invalid をextendする。
application.scss
.field_with_errors {
  input {
    @extend .is-invalid;
  }
}
16
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?