forms: fix form validation error messages.

* Fix it so that all edit forms show an error banner if the form
  has validation errors. Previously forms had to manually call
  `error_messages_for`, which not all forms did.

* Fix it so that the full validation error message is shown next to each
  input attribute that had errors. Also update the styling of these
  error messages to look better.
This commit is contained in:
evazion
2021-02-22 01:36:54 -06:00
parent b9ea9d2f5a
commit cde76e66f6
24 changed files with 24 additions and 72 deletions

View File

@@ -57,13 +57,13 @@ SimpleForm.setup do |config|
# b.use :input, class: 'input', error_class: 'is-invalid', valid_class: 'is-valid'
b.use :label_input
b.use :hint, wrap_with: { tag: :span, class: :hint }
b.use :error, wrap_with: { tag: :span, class: :error }
# b.use :error, wrap_with: { tag: :span, class: :error }
## full_messages_for
# If you want to display the full error message for the attribute, you can
# use the component :full_error, like:
#
# b.use :full_error, wrap_with: { tag: :span, class: :error }
b.use :full_error, wrap_with: { tag: :span, class: :error }
end
# The default wrapper to be used by the FormBuilder.
@@ -87,7 +87,7 @@ SimpleForm.setup do |config|
# Method used to tidy up errors. Specify any Rails Array method.
# :first lists the first message for each field.
# Use :to_sentence to list all errors for each field.
# config.error_method = :first
config.error_method = :to_sentence
# Default tag used for error notification helper.
config.error_notification_tag = :div