chore(form): InputComponent with asterisk on required inputs

This commit is contained in:
Colin Darie 2023-10-02 15:31:32 +02:00
parent b85a897237
commit 1fbfc9fce1
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
2 changed files with 9 additions and 0 deletions

View file

@ -67,6 +67,10 @@ class Dsfr::InputComponent < ApplicationComponent
@input_type == :email_field
end
def required?
@required
end
def show_password_id
dom_id(object, "#{@attribute}_show_password")
end

View file

@ -2,8 +2,13 @@
= @form.label @attribute, label_opts do
- capture do
= label
- if required?
= render EditableChamp::AsteriskMandatoryComponent.new
- if hint?
%span.fr-hint-text= hint
= @form.public_send(@input_type, @attribute, input_opts)
- if errors_on_attribute?