From e3748c853fd6bcc355d32b73d6fdcf88fea10522 Mon Sep 17 00:00:00 2001 From: jacs Date: Tue, 15 Apr 2025 07:23:34 -0500 Subject: [PATCH] template with select multiple, input custom attribute --- template/components/form_input.go | 6 ++++++ template/components/form_input.html | 5 +++++ template/components/form_select.go | 1 + template/components/form_select.html | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/template/components/form_input.go b/template/components/form_input.go index d1264ec..0ee8150 100644 --- a/template/components/form_input.go +++ b/template/components/form_input.go @@ -11,4 +11,10 @@ type FormInput struct { IsDisabled bool Autocomplete bool IsRequired bool + CustomAtt []CustomAtt +} + +type CustomAtt struct { + AttName string + AttValue string } diff --git a/template/components/form_input.html b/template/components/form_input.html index 6103b76..adf33e8 100644 --- a/template/components/form_input.html +++ b/template/components/form_input.html @@ -14,6 +14,11 @@ {{if ne .Value ""}} value="{{.Value}}" {{end}} + {{if .CustomAtt }} + {{range $options := .CustomAtt}} + {{$options.AttName}}="{{$options.AttValue}}" + {{end}} + {{end}} aria-describedby="{{.ID}}Help"> {{if ne .Hint ""}}{{.Hint}}{{end}} {{if ne .Error ""}}
{{.Error}}
{{end}} diff --git a/template/components/form_select.go b/template/components/form_select.go index db94fe3..ea10ea5 100644 --- a/template/components/form_select.go +++ b/template/components/form_select.go @@ -5,6 +5,7 @@ type FormSelect struct { SelectedOption FormSelectOption Label string AllOptions []FormSelectOption + IsMultiple bool } type FormSelectOption struct { diff --git a/template/components/form_select.html b/template/components/form_select.html index 6317e6b..eb222e5 100644 --- a/template/components/form_select.html +++ b/template/components/form_select.html @@ -1,7 +1,7 @@ {{define "form_select"}}
- {{range $options := .AllOptions}} {{end}}