feat(champs.errors.format): better format for error below champs

Co-authored-by: Corinne Durrmeyer <corinne@inseo.fr>
This commit is contained in:
mfo 2024-04-08 16:36:37 +02:00
parent 938f5043a4
commit 35c92ee906
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
3 changed files with 9 additions and 4 deletions

View file

@ -1,9 +1,10 @@
module Dsfr module Dsfr
class InputStatusMessageComponent < ApplicationComponent class InputStatusMessageComponent < ApplicationComponent
def initialize(errors_on_attribute:, error_full_messages:, described_by:) def initialize(errors_on_attribute:, error_full_messages:, described_by:, champ:)
@errors_on_attribute = errors_on_attribute @errors_on_attribute = errors_on_attribute
@error_full_messages = error_full_messages @error_full_messages = error_full_messages
@described_by = described_by @described_by = described_by
@champ = champ
end end
def render? def render?

View file

@ -1,3 +1,7 @@
.fr-messages-group{ id: @describedby_id } .fr-messages-group{ id: @describedby_id }
- @error_full_messages.each do |error_message| - if @error_full_messages.size > 0
%p{ class: class_names('fr-message' => true, "fr-message--#{@errors_on_attribute ? 'error' : 'valid'}" => true) }= error_message %p{ class: class_names('fr-message' => true, "fr-message--#{@errors_on_attribute ? 'error' : 'valid'}" => true) }
= "« #{@champ.libelle} » "
- @error_full_messages.each do |error_message|
= error_message

View file

@ -5,6 +5,6 @@
= render champ_component = render champ_component
= render Dsfr::InputStatusMessageComponent.new(errors_on_attribute: champ_component.errors_on_attribute?, error_full_messages: champ_component.error_full_messages, described_by: @champ.describedby_id) = render Dsfr::InputStatusMessageComponent.new(errors_on_attribute: champ_component.errors_on_attribute?, error_full_messages: champ_component.error_full_messages, described_by: @champ.describedby_id, champ: @champ)
= @form.hidden_field :id, value: @champ.id = @form.hidden_field :id, value: @champ.id