feat(champs.errors.format): better format for error below champs
Co-authored-by: Corinne Durrmeyer <corinne@inseo.fr>
This commit is contained in:
parent
938f5043a4
commit
35c92ee906
3 changed files with 9 additions and 4 deletions
|
@ -1,9 +1,10 @@
|
|||
module Dsfr
|
||||
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
|
||||
@error_full_messages = error_full_messages
|
||||
@described_by = described_by
|
||||
@champ = champ
|
||||
end
|
||||
|
||||
def render?
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
.fr-messages-group{ id: @describedby_id }
|
||||
- @error_full_messages.each do |error_message|
|
||||
%p{ class: class_names('fr-message' => true, "fr-message--#{@errors_on_attribute ? 'error' : 'valid'}" => true) }= error_message
|
||||
- if @error_full_messages.size > 0
|
||||
%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
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
|
||||
= 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
|
||||
|
|
Loading…
Reference in a new issue