diff --git a/internal/http/handler/webui/common/component/field.templ b/internal/http/handler/webui/common/component/field.templ index 720d47b..9e4383a 100644 --- a/internal/http/handler/webui/common/component/field.templ +++ b/internal/http/handler/webui/common/component/field.templ @@ -21,7 +21,28 @@ templ FormField(form *form.Form, id string, name string, label string) { } } -templ FormTextarea(form *form.Form, id string, name string, label string) { +type FormTextareaOptions struct { + Attrs map[string]any +} + +type FormTextareaOptionFunc func(opts *FormTextareaOptions) + +func WithTextareaAttrs(kvAttrs ...any) FormTextareaOptionFunc { + return func(opts *FormTextareaOptions) { + opts.Attrs = keyValuesToAttrs(kvAttrs) + } +} + +func newFormTextareaOptions(funcs ...FormTextareaOptionFunc) *FormTextareaOptions { + opts := &FormTextareaOptions{} + for _, fn := range funcs { + fn(opts) + } + return opts +} + +templ FormTextarea(form *form.Form, id string, name string, label string, funcs ...FormTextareaOptionFunc) { + {{ opts := newFormTextareaOptions(funcs...) }} {{ field := form.Field(name) }} if field != nil {
@@ -29,7 +50,7 @@ templ FormTextarea(form *form.Form, id string, name string, label string) {
{{ err, hasErr := form.Error(name) }} {{ value, hasValue := field.Get("value") }} -