feat: very basic validation

This commit is contained in:
Adriano Caloiaro 2025-01-10 11:52:12 -07:00
parent 4d2415f9a9
commit 569c33ca14
No known key found for this signature in database
GPG key ID: C2BC56DE73CE3F75
11 changed files with 390 additions and 182 deletions

2
frm.go
View file

@ -165,6 +165,6 @@ func CollectorPathForm(ctx context.Context, formID int64, path ...string) string
if !ok {
return "/"
}
base = filepath.Clean(fmt.Sprintf("%s/collect", base))
base = filepath.Clean(base)
return fmt.Sprintf("%s/%d", base, formID)
}

100
handlers/collector.go Normal file
View file

@ -0,0 +1,100 @@
package handlers
import (
"log/slog"
"maps"
"net/http"
"net/url"
"slices"
"github.com/acaloiaro/frm"
"github.com/acaloiaro/frm/internal"
"github.com/acaloiaro/frm/types"
"github.com/acaloiaro/frm/ui"
)
// View renders the form viewer for the collector
func View(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
i, err := frm.Instance(ctx)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
formID, err := formID(ctx)
if err != nil {
w.WriteHeader(http.StatusNotFound)
return
}
f, err := internal.Q(ctx, i.DBArgs).GetForm(ctx, internal.GetFormParams{
WorkspaceID: i.WorkspaceID,
ID: *formID,
})
if err != nil {
w.WriteHeader(http.StatusNotFound)
return
}
// Render the form collector
err = ui.Viewer((frm.Form)(f)).Render(ctx, w)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
}
}
// Collect handles collector form submissions
func Collect(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
i, err := frm.Instance(ctx)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
formID, err := formID(ctx)
if err != nil {
w.WriteHeader(http.StatusNotFound)
return
}
f, err := internal.Q(ctx, i.DBArgs).GetForm(ctx, internal.GetFormParams{
WorkspaceID: i.WorkspaceID,
ID: *formID,
})
if err != nil {
w.WriteHeader(http.StatusNotFound)
return
}
err = r.ParseForm()
if err != nil {
slog.Error("[collector] unable to parse form", "error", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
errs := validate(f, r.Form)
if errs.Any() {
slog.Info("[collector] failed validation", "errors", errs)
w.WriteHeader(http.StatusBadRequest)
} else {
w.Header().Add("hx-redirect", frm.CollectorPathForm(ctx, *formID))
w.WriteHeader(http.StatusOK)
}
allFields := slices.Collect(maps.Keys(f.Fields))
err = ui.Validation(allFields, errs).Render(ctx, w)
if err != nil {
slog.Error("[collector] error while reporting validation error", "error", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
}
// validate validates forms
func validate(f internal.Form, submission url.Values) (errs types.ValidationErrors) {
errs = types.ValidationErrors{}
for submittedFieldID := range maps.Keys(submission) {
field := f.Fields[submittedFieldID]
formFieldValue := submission[submittedFieldID]
if err := field.Validate(formFieldValue); err != nil {
errs[submittedFieldID] = err
}
}
return errs
}

View file

@ -734,61 +734,3 @@ func toFormFieldOption(field types.FormField, options []string) types.FieldOptio
return fieldOptions
}
// View renders the form viewer for the collector
func View(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
i, err := frm.Instance(ctx)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
formID, err := formID(ctx)
if err != nil {
w.WriteHeader(http.StatusNotFound)
return
}
f, err := internal.Q(ctx, i.DBArgs).GetForm(ctx, internal.GetFormParams{
WorkspaceID: i.WorkspaceID,
ID: *formID,
})
if err != nil {
w.WriteHeader(http.StatusNotFound)
return
}
// Render the form collector
err = ui.Viewer((frm.Form)(f)).Render(ctx, w)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
}
}
// Collect handles collector form submissions
func Collect(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
i, err := frm.Instance(ctx)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
formID, err := formID(ctx)
if err != nil {
w.WriteHeader(http.StatusNotFound)
return
}
f, err := internal.Q(ctx, i.DBArgs).GetForm(ctx, internal.GetFormParams{
WorkspaceID: i.WorkspaceID,
ID: *formID,
})
if err != nil {
w.WriteHeader(http.StatusNotFound)
return
}
// Render the form collector
err = ui.Viewer((frm.Form)(f)).Render(ctx, w)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
}
}

View file

@ -2850,6 +2850,11 @@ input.tab:checked + .tab-content,
color: inherit;
}
.text-red-400 {
--tw-text-opacity: 1;
color: rgb(255 153 153 / var(--tw-text-opacity));
}
.text-red-500 {
--tw-text-opacity: 1;
color: rgb(255 119 119 / var(--tw-text-opacity));

View file

@ -2,10 +2,21 @@ package types
import (
"encoding/json"
"errors"
"github.com/google/uuid"
)
// ErrRequiredNoValueProvided is a form validation error for required fields missing values
var ErrRequiredNoValueProvided = errors.New("This field is required")
// ValidationErrors is a mapping of form field IDs to the errors validating values submitted to those fields
type ValidationErrors map[string]error
func (v ValidationErrors) Any() bool {
return len(v) > 0
}
// FormFieldType enum enumerates all possible form field types
//
//go:generate enumer -type FormFieldType -trimprefix FormFieldType -transform=snake -json
@ -99,6 +110,21 @@ func (f FormFieldSortByOrder) Len() int { return len(f) }
func (f FormFieldSortByOrder) Swap(i, j int) { f[i], f[j] = f[j], f[i] }
func (f FormFieldSortByOrder) Less(i, j int) bool { return f[i].Order < f[j].Order }
// Validate validates values submitted to a form field
func (f FormField) Validate(value []string) (err error) {
if f.Required {
if len(value) == 0 {
return ErrRequiredNoValueProvided
}
for _, ffv := range value {
if ffv == "" {
return ErrRequiredNoValueProvided
}
}
}
return nil
}
// MarshalJSON implements the json.Marshaler interface for FormFieldType
func (f FormField) MarshalJSON() ([]byte, error) {
id := uuid.Nil

View file

@ -240,8 +240,7 @@ templ App(pageTitle string) {
<!DOCTYPE html>
<html lang="eng">
@head(pageTitle)
<body class="">
<div id="errors"></div>
<body>
<main hx-ext="response-targets">
{ children... }
</main>
@ -846,6 +845,10 @@ templ FormView(form frm.Form, isPreview bool) {
class="flex flex-col py-3"
}
>
<div
id={ fmt.Sprintf("errors-%s", field.ID.String()) }
class="text-red-400"
></div>
switch field.Type {
case types.FormFieldTypeTextSingle:
@fieldLabel(field)
@ -871,14 +874,16 @@ templ FormView(form frm.Form, isPreview bool) {
></textarea>
case types.FormFieldTypeSingleSelect, types.FormFieldTypeMultiSelect:
@selector.Selector(selector.SelectArgs{
ID: field.ID.String(),
Name: field.ID.String(),
Label: field.Label,
Required: field.Required,
Placeholder: field.Placeholder,
Multiple: field.Type == types.FormFieldTypeMultiSelect,
Options: toSelectorOpts(field.Options, false),
Hyperscript: fmt.Sprintf("on change trigger field_change(field_id: '%s', value: my.value)", field.ID.String()),
ID: field.ID.String(),
Name: field.ID.String(),
Label: field.Label,
Required: field.Required,
Placeholder: field.Placeholder,
Multiple: field.Type == types.FormFieldTypeMultiSelect,
Options: toSelectorOpts(field.Options, false),
SearchDisabled: true,
EditItems: false,
Hyperscript: fmt.Sprintf("on change trigger field_change(field_id: '%s', value: my.value)", field.ID.String()),
})
}
</div>
@ -889,11 +894,12 @@ templ FormView(form frm.Form, isPreview bool) {
Type: "submit",
Classes: []string{"flex-grow", "justify-center", "uppercase"},
}, templ.Attributes{
"type": "submit",
"data-hx-post": formCollectorUrl[string](ctx, form),
"data-hx-trigger": "click",
"data-hx-swap": "none",
"disabled": isPreview,
"type": "submit",
"data-hx-post": formCollectorUrl[string](ctx, form),
"data-hx-trigger": "click",
"data-hx-swap": "none",
"data-hx-target-400": "form",
"disabled": isPreview,
},
)
</form>
@ -901,6 +907,10 @@ templ FormView(form frm.Form, isPreview bool) {
}
func toSelectorOpts(opts []types.Option, selectAll bool) (sopts []selector.Option) {
// TODO: Fix -- adding an empty option because the first select <option> is selected by default, for some reason
sopts = append(sopts, (selector.Option)(selector.Option{
Value: "",
}))
for _, opt := range opts {
if selectAll {
opt.Selected = true
@ -930,3 +940,7 @@ func sortFields(fields types.FormFields) (sorted []types.FormField) {
func f(s string, args ...any) string {
return fmt.Sprintf(s, args...)
}
func domID(s string) string {
return strings.ReplaceAll(s, "-", "")
}

View file

@ -867,7 +867,7 @@ func FormSettings(form frm.Form) templ.Component {
var templ_7745c5c3_Var39 string
templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(formUrl[string](ctx, form, "/settings"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 284, Col: 56}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 283, Col: 56}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39))
if templ_7745c5c3_Err != nil {
@ -880,7 +880,7 @@ func FormSettings(form frm.Form) templ.Component {
var templ_7745c5c3_Var40 string
templ_7745c5c3_Var40, templ_7745c5c3_Err = templ.JoinStringErrs(FormSettingsUpdateEvent)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 285, Col: 44}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 284, Col: 44}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var40))
if templ_7745c5c3_Err != nil {
@ -901,7 +901,7 @@ func FormSettings(form frm.Form) templ.Component {
var templ_7745c5c3_Var41 string
templ_7745c5c3_Var41, templ_7745c5c3_Err = templ.JoinStringErrs(form.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 299, Col: 21}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 298, Col: 21}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var41))
if templ_7745c5c3_Err != nil {
@ -914,7 +914,7 @@ func FormSettings(form frm.Form) templ.Component {
var templ_7745c5c3_Var42 string
templ_7745c5c3_Var42, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on keyup debounced at 600ms trigger '%s'", FormSettingsUpdateEvent))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 302, Col: 88}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 301, Col: 88}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var42))
if templ_7745c5c3_Err != nil {
@ -1150,7 +1150,7 @@ func FormFieldsForm(form frm.Form) templ.Component {
var templ_7745c5c3_Var49 string
templ_7745c5c3_Var49, templ_7745c5c3_Err = templ.JoinStringErrs(formUrl[string](ctx, form, "/fields/order"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 360, Col: 60}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 359, Col: 60}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var49))
if templ_7745c5c3_Err != nil {
@ -1168,7 +1168,7 @@ func FormFieldsForm(form frm.Form) templ.Component {
var templ_7745c5c3_Var50 string
templ_7745c5c3_Var50, templ_7745c5c3_Err = templ.JoinStringErrs(field.ID.String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 369, Col: 65}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 368, Col: 65}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var50))
if templ_7745c5c3_Err != nil {
@ -1181,7 +1181,7 @@ func FormFieldsForm(form frm.Form) templ.Component {
var templ_7745c5c3_Var51 string
templ_7745c5c3_Var51, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on click add .hidden to .active-configurator then take .active-configurator from .active-configurator for #configure-%s then remove .hidden from #configure-%s", field.ID.String(), field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 375, Col: 223}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 374, Col: 223}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var51))
if templ_7745c5c3_Err != nil {
@ -1194,7 +1194,7 @@ func FormFieldsForm(form frm.Form) templ.Component {
var templ_7745c5c3_Var52 string
templ_7745c5c3_Var52, templ_7745c5c3_Err = templ.JoinStringErrs(field.Label)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 379, Col: 65}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 378, Col: 65}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var52))
if templ_7745c5c3_Err != nil {
@ -1326,7 +1326,7 @@ func builderColumnRight(form frm.Form) templ.Component {
var templ_7745c5c3_Var55 string
templ_7745c5c3_Var55, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(i))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 447, Col: 32}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 446, Col: 32}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var55))
if templ_7745c5c3_Err != nil {
@ -1339,7 +1339,7 @@ func builderColumnRight(form frm.Form) templ.Component {
var templ_7745c5c3_Var56 string
templ_7745c5c3_Var56, templ_7745c5c3_Err = templ.JoinStringErrs(formUrl[string](ctx, form, "/fields"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 450, Col: 60}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 449, Col: 60}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var56))
if templ_7745c5c3_Err != nil {
@ -1352,7 +1352,7 @@ func builderColumnRight(form frm.Form) templ.Component {
var templ_7745c5c3_Var57 string
templ_7745c5c3_Var57, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf(`{"field_type": "%s"}`, fieldType))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 452, Col: 69}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 451, Col: 69}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var57))
if templ_7745c5c3_Err != nil {
@ -1429,7 +1429,7 @@ func FormFieldConfigurator(form frm.Form) templ.Component {
var templ_7745c5c3_Var59 string
templ_7745c5c3_Var59, templ_7745c5c3_Err = templ.JoinStringErrs(formUrl[string](ctx, form, "/fields"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 483, Col: 53}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 482, Col: 53}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var59))
if templ_7745c5c3_Err != nil {
@ -1442,7 +1442,7 @@ func FormFieldConfigurator(form frm.Form) templ.Component {
var templ_7745c5c3_Var60 string
templ_7745c5c3_Var60, templ_7745c5c3_Err = templ.JoinStringErrs(FieldsFormUpdateEvent)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 484, Col: 41}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 483, Col: 41}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var60))
if templ_7745c5c3_Err != nil {
@ -1460,7 +1460,7 @@ func FormFieldConfigurator(form frm.Form) templ.Component {
var templ_7745c5c3_Var61 string
templ_7745c5c3_Var61, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("configure-%s", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 489, Col: 59}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 488, Col: 59}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var61))
if templ_7745c5c3_Err != nil {
@ -1481,7 +1481,7 @@ func FormFieldConfigurator(form frm.Form) templ.Component {
var templ_7745c5c3_Var62 string
templ_7745c5c3_Var62, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("configurator-tabs-%s", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 493, Col: 68}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 492, Col: 68}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var62))
if templ_7745c5c3_Err != nil {
@ -1564,7 +1564,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var64 string
templ_7745c5c3_Var64, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("field-%s-settings", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 517, Col: 62}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 516, Col: 62}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var64))
if templ_7745c5c3_Err != nil {
@ -1577,7 +1577,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var65 string
templ_7745c5c3_Var65, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "required"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 518, Col: 48}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 517, Col: 48}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var65))
if templ_7745c5c3_Err != nil {
@ -1590,7 +1590,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var66 string
templ_7745c5c3_Var66, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(field.Required))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 518, Col: 99}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 517, Col: 99}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var66))
if templ_7745c5c3_Err != nil {
@ -1603,7 +1603,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var67 string
templ_7745c5c3_Var67, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "hidden"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 519, Col: 46}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 518, Col: 46}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var67))
if templ_7745c5c3_Err != nil {
@ -1616,7 +1616,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var68 string
templ_7745c5c3_Var68, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(field.Hidden))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 519, Col: 95}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 518, Col: 95}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var68))
if templ_7745c5c3_Err != nil {
@ -1629,7 +1629,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var69 string
templ_7745c5c3_Var69, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "field_type"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 520, Col: 50}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 519, Col: 50}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var69))
if templ_7745c5c3_Err != nil {
@ -1642,7 +1642,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var70 string
templ_7745c5c3_Var70, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprint(field.Type))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 520, Col: 97}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 519, Col: 97}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var70))
if templ_7745c5c3_Err != nil {
@ -1655,7 +1655,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var71 string
templ_7745c5c3_Var71, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "label"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 522, Col: 45}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 521, Col: 45}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var71))
if templ_7745c5c3_Err != nil {
@ -1676,7 +1676,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var72 string
templ_7745c5c3_Var72, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "label"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 528, Col: 37}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 527, Col: 37}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var72))
if templ_7745c5c3_Err != nil {
@ -1689,7 +1689,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var73 string
templ_7745c5c3_Var73, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "label"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 529, Col: 39}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 528, Col: 39}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var73))
if templ_7745c5c3_Err != nil {
@ -1702,7 +1702,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var74 string
templ_7745c5c3_Var74, templ_7745c5c3_Err = templ.JoinStringErrs(field.Label)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 532, Col: 22}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 531, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var74))
if templ_7745c5c3_Err != nil {
@ -1715,7 +1715,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var75 string
templ_7745c5c3_Var75, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on keyup debounced at 600ms trigger '%s'", FieldsFormUpdateEvent))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 534, Col: 85}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 533, Col: 85}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var75))
if templ_7745c5c3_Err != nil {
@ -1728,7 +1728,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var76 string
templ_7745c5c3_Var76, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "placeholder"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 537, Col: 51}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 536, Col: 51}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var76))
if templ_7745c5c3_Err != nil {
@ -1741,7 +1741,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var77 string
templ_7745c5c3_Var77, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "placeholder"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 542, Col: 43}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 541, Col: 43}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var77))
if templ_7745c5c3_Err != nil {
@ -1754,7 +1754,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var78 string
templ_7745c5c3_Var78, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "placeholder"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 543, Col: 45}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 542, Col: 45}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var78))
if templ_7745c5c3_Err != nil {
@ -1767,7 +1767,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var79 string
templ_7745c5c3_Var79, templ_7745c5c3_Err = templ.JoinStringErrs(field.Placeholder)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 546, Col: 28}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 545, Col: 28}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var79))
if templ_7745c5c3_Err != nil {
@ -1780,7 +1780,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var80 string
templ_7745c5c3_Var80, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on keyup debounced at 600ms trigger '%s'", FieldsFormUpdateEvent))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 548, Col: 85}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 547, Col: 85}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var80))
if templ_7745c5c3_Err != nil {
@ -1798,7 +1798,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var81 string
templ_7745c5c3_Var81, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "options"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 552, Col: 48}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 551, Col: 48}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var81))
if templ_7745c5c3_Err != nil {
@ -1828,7 +1828,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var82 string
templ_7745c5c3_Var82, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "required"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 567, Col: 48}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 566, Col: 48}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var82))
if templ_7745c5c3_Err != nil {
@ -1841,7 +1841,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var83 string
templ_7745c5c3_Var83, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "required"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 572, Col: 40}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 571, Col: 40}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var83))
if templ_7745c5c3_Err != nil {
@ -1854,7 +1854,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var84 string
templ_7745c5c3_Var84, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "required"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 573, Col: 42}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 572, Col: 42}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var84))
if templ_7745c5c3_Err != nil {
@ -1883,7 +1883,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
then trigger '%s'`,
fieldName(field, "", "hidden"), FieldsFormUpdateEvent))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 585, Col: 59}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 584, Col: 59}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var85))
if templ_7745c5c3_Err != nil {
@ -1896,7 +1896,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var86 string
templ_7745c5c3_Var86, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "hidden"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 588, Col: 46}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 587, Col: 46}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var86))
if templ_7745c5c3_Err != nil {
@ -1909,7 +1909,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var87 string
templ_7745c5c3_Var87, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "hidden"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 593, Col: 38}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 592, Col: 38}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var87))
if templ_7745c5c3_Err != nil {
@ -1922,7 +1922,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
var templ_7745c5c3_Var88 string
templ_7745c5c3_Var88, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, "", "hidden"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 594, Col: 40}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 593, Col: 40}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var88))
if templ_7745c5c3_Err != nil {
@ -1951,7 +1951,7 @@ func fieldSettingsConfiguration(form frm.Form, field types.FormField) templ.Comp
then trigger '%s'`,
fieldName(field, "", "required"), FieldsFormUpdateEvent))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 606, Col: 61}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 605, Col: 61}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var89))
if templ_7745c5c3_Err != nil {
@ -2005,7 +2005,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone
var templ_7745c5c3_Var91 string
templ_7745c5c3_Var91, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("field-%s-logic", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 622, Col: 59}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 621, Col: 59}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var91))
if templ_7745c5c3_Err != nil {
@ -2018,7 +2018,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone
var templ_7745c5c3_Var92 string
templ_7745c5c3_Var92, templ_7745c5c3_Err = templ.JoinStringErrs(frm.URLPath(ctx, fmt.Sprintf("/build/%d/logic_configurator/%s/step3", form.ID, field.ID.String())))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 625, Col: 116}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 624, Col: 116}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var92))
if templ_7745c5c3_Err != nil {
@ -2031,7 +2031,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone
var templ_7745c5c3_Var93 string
templ_7745c5c3_Var93, templ_7745c5c3_Err = templ.JoinStringErrs(LogicConfiguratorTargetFieldSelected)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 626, Col: 58}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 625, Col: 58}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var93))
if templ_7745c5c3_Err != nil {
@ -2044,7 +2044,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone
var templ_7745c5c3_Var94 string
templ_7745c5c3_Var94, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("#logic-field-value-chooser-%s", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 628, Col: 84}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 627, Col: 84}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var94))
if templ_7745c5c3_Err != nil {
@ -2087,7 +2087,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone
var templ_7745c5c3_Var95 string
templ_7745c5c3_Var95, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("logic-field-value-chooser-%s", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 653, Col: 71}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 652, Col: 71}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var95))
if templ_7745c5c3_Err != nil {
@ -2110,7 +2110,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone
var templ_7745c5c3_Var96 string
templ_7745c5c3_Var96, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s-logic-action", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 663, Col: 58}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 662, Col: 58}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var96))
if templ_7745c5c3_Err != nil {
@ -2123,7 +2123,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone
var templ_7745c5c3_Var97 string
templ_7745c5c3_Var97, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, FieldGroupLogic, types.FieldLogicTriggerShow.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 666, Col: 82}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 665, Col: 82}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var97))
if templ_7745c5c3_Err != nil {
@ -2149,7 +2149,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone
trigger '%s'`,
FieldsFormUpdateEvent))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 673, Col: 28}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 672, Col: 28}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var98))
if templ_7745c5c3_Err != nil {
@ -2162,7 +2162,7 @@ func fieldLogicConfiguration(form frm.Form, field types.FormField) templ.Compone
var templ_7745c5c3_Var99 string
templ_7745c5c3_Var99, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s-logic-action", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 675, Col: 65}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 674, Col: 65}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var99))
if templ_7745c5c3_Err != nil {
@ -2243,7 +2243,7 @@ func LogicConfiguratorStepThree(form frm.Form, field types.FormField, targetFiel
var templ_7745c5c3_Var101 string
templ_7745c5c3_Var101, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s-logic-chosen-field-value", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 718, Col: 70}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 717, Col: 70}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var101))
if templ_7745c5c3_Err != nil {
@ -2256,7 +2256,7 @@ func LogicConfiguratorStepThree(form frm.Form, field types.FormField, targetFiel
var templ_7745c5c3_Var102 string
templ_7745c5c3_Var102, templ_7745c5c3_Err = templ.JoinStringErrs(fieldName(field, FieldGroupLogic, FieldLogicTargetFieldValue))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 719, Col: 72}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 718, Col: 72}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var102))
if templ_7745c5c3_Err != nil {
@ -2274,7 +2274,7 @@ func LogicConfiguratorStepThree(form frm.Form, field types.FormField, targetFiel
var templ_7745c5c3_Var103 string
templ_7745c5c3_Var103, templ_7745c5c3_Err = templ.JoinStringErrs(field.Logic.TriggerValues[0])
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 724, Col: 41}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 723, Col: 41}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var103))
if templ_7745c5c3_Err != nil {
@ -2292,7 +2292,7 @@ func LogicConfiguratorStepThree(form frm.Form, field types.FormField, targetFiel
var templ_7745c5c3_Var104 string
templ_7745c5c3_Var104, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on keyup debounced at 600ms trigger '%s'", FieldsFormUpdateEvent))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 726, Col: 86}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 725, Col: 86}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var104))
if templ_7745c5c3_Err != nil {
@ -2454,7 +2454,7 @@ func fieldLabel(field types.FormField) templ.Component {
var templ_7745c5c3_Var107 string
templ_7745c5c3_Var107, templ_7745c5c3_Err = templ.JoinStringErrs(field.ID.String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 805, Col: 31}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 804, Col: 31}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var107))
if templ_7745c5c3_Err != nil {
@ -2467,7 +2467,7 @@ func fieldLabel(field types.FormField) templ.Component {
var templ_7745c5c3_Var108 string
templ_7745c5c3_Var108, templ_7745c5c3_Err = templ.JoinStringErrs(field.Label)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 806, Col: 15}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 805, Col: 15}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var108))
if templ_7745c5c3_Err != nil {
@ -2534,7 +2534,7 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
var templ_7745c5c3_Var110 string
templ_7745c5c3_Var110, templ_7745c5c3_Err = templ.JoinStringErrs(ViewerMetadata{Form: form}.JSON())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 832, Col: 48}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 831, Col: 48}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var110))
if templ_7745c5c3_Err != nil {
@ -2547,7 +2547,7 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
var templ_7745c5c3_Var111 string
templ_7745c5c3_Var111, templ_7745c5c3_Err = templ.JoinStringErrs(form.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 835, Col: 14}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 834, Col: 14}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var111))
if templ_7745c5c3_Err != nil {
@ -2565,7 +2565,7 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
var templ_7745c5c3_Var112 string
templ_7745c5c3_Var112, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("field-container-%s", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 842, Col: 62}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 841, Col: 62}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var112))
if templ_7745c5c3_Err != nil {
@ -2590,25 +2590,25 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var113 string
templ_7745c5c3_Var113, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("errors-%s", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 849, Col: 54}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var113))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 168)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
switch field.Type {
case types.FormFieldTypeTextSingle:
templ_7745c5c3_Err = fieldLabel(field).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 168)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var113 string
templ_7745c5c3_Var113, templ_7745c5c3_Err = templ.JoinStringErrs(field.ID.String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 853, Col: 30}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var113))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 169)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
@ -2616,7 +2616,7 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
var templ_7745c5c3_Var114 string
templ_7745c5c3_Var114, templ_7745c5c3_Err = templ.JoinStringErrs(field.ID.String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 854, Col: 32}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 856, Col: 30}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var114))
if templ_7745c5c3_Err != nil {
@ -2627,9 +2627,9 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var115 string
templ_7745c5c3_Var115, templ_7745c5c3_Err = templ.JoinStringErrs(field.Placeholder)
templ_7745c5c3_Var115, templ_7745c5c3_Err = templ.JoinStringErrs(field.ID.String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 855, Col: 39}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 857, Col: 32}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var115))
if templ_7745c5c3_Err != nil {
@ -2640,9 +2640,9 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var116 string
templ_7745c5c3_Var116, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on keyup debounced at 250ms trigger field_change(field_id: '%s', value: my.value)", field.ID.String()))
templ_7745c5c3_Var116, templ_7745c5c3_Err = templ.JoinStringErrs(field.Placeholder)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 858, Col: 127}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 858, Col: 39}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var116))
if templ_7745c5c3_Err != nil {
@ -2652,8 +2652,12 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
case types.FormFieldTypeTextMultiple:
templ_7745c5c3_Err = fieldLabel(field).Render(ctx, templ_7745c5c3_Buffer)
var templ_7745c5c3_Var117 string
templ_7745c5c3_Var117, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on keyup debounced at 250ms trigger field_change(field_id: '%s', value: my.value)", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 861, Col: 127}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var117))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -2661,12 +2665,8 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var117 string
templ_7745c5c3_Var117, templ_7745c5c3_Err = templ.JoinStringErrs(field.ID.String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 863, Col: 30}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var117))
case types.FormFieldTypeTextMultiple:
templ_7745c5c3_Err = fieldLabel(field).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -2677,7 +2677,7 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
var templ_7745c5c3_Var118 string
templ_7745c5c3_Var118, templ_7745c5c3_Err = templ.JoinStringErrs(field.ID.String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 864, Col: 32}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 866, Col: 30}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var118))
if templ_7745c5c3_Err != nil {
@ -2688,9 +2688,9 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var119 string
templ_7745c5c3_Var119, templ_7745c5c3_Err = templ.JoinStringErrs(field.Placeholder)
templ_7745c5c3_Var119, templ_7745c5c3_Err = templ.JoinStringErrs(field.ID.String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 867, Col: 39}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 867, Col: 32}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var119))
if templ_7745c5c3_Err != nil {
@ -2701,9 +2701,9 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var120 string
templ_7745c5c3_Var120, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on keyup debounced at 250ms trigger field_change(field_id: '%s', value: my.value)", field.ID.String()))
templ_7745c5c3_Var120, templ_7745c5c3_Err = templ.JoinStringErrs(field.Placeholder)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 870, Col: 127}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 870, Col: 39}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var120))
if templ_7745c5c3_Err != nil {
@ -2713,27 +2713,42 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var121 string
templ_7745c5c3_Var121, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("on keyup debounced at 250ms trigger field_change(field_id: '%s', value: my.value)", field.ID.String()))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 873, Col: 127}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var121))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 178)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
case types.FormFieldTypeSingleSelect, types.FormFieldTypeMultiSelect:
templ_7745c5c3_Err = selector.Selector(selector.SelectArgs{
ID: field.ID.String(),
Name: field.ID.String(),
Label: field.Label,
Required: field.Required,
Placeholder: field.Placeholder,
Multiple: field.Type == types.FormFieldTypeMultiSelect,
Options: toSelectorOpts(field.Options, false),
Hyperscript: fmt.Sprintf("on change trigger field_change(field_id: '%s', value: my.value)", field.ID.String()),
ID: field.ID.String(),
Name: field.ID.String(),
Label: field.Label,
Required: field.Required,
Placeholder: field.Placeholder,
Multiple: field.Type == types.FormFieldTypeMultiSelect,
Options: toSelectorOpts(field.Options, false),
SearchDisabled: true,
EditItems: false,
Hyperscript: fmt.Sprintf("on change trigger field_change(field_id: '%s', value: my.value)", field.ID.String()),
}).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 178)
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 179)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 179)
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 180)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -2742,17 +2757,18 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
Type: "submit",
Classes: []string{"flex-grow", "justify-center", "uppercase"},
}, templ.Attributes{
"type": "submit",
"data-hx-post": formCollectorUrl[string](ctx, form),
"data-hx-trigger": "click",
"data-hx-swap": "none",
"disabled": isPreview,
"type": "submit",
"data-hx-post": formCollectorUrl[string](ctx, form),
"data-hx-trigger": "click",
"data-hx-swap": "none",
"data-hx-target-400": "form",
"disabled": isPreview,
},
).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 180)
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 181)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -2761,6 +2777,10 @@ func FormView(form frm.Form, isPreview bool) templ.Component {
}
func toSelectorOpts(opts []types.Option, selectAll bool) (sopts []selector.Option) {
// TODO: Fix -- adding an empty option because the first select <option> is selected by default, for some reason
sopts = append(sopts, (selector.Option)(selector.Option{
Value: "",
}))
for _, opt := range opts {
if selectAll {
opt.Selected = true
@ -2791,4 +2811,8 @@ func f(s string, args ...any) string {
return fmt.Sprintf(s, args...)
}
func domID(s string) string {
return strings.ReplaceAll(s, "-", "")
}
var _ = templruntime.GeneratedTemplate

View file

@ -33,7 +33,7 @@
\"></script> <script type=\"text/javascript\">\n\t\t\t\thtmx.onLoad(function(content) {\n\t\t\t\t var sortables = content.querySelectorAll(\".sortable\");\n\t\t\t\t for (var i = 0; i < sortables.length; i++) {\n\t\t\t\t var sortable = sortables[i];\n\t\t\t\t var sortableInstance = new Sortable(sortable, {\n\t\t\t\t animation: 150,\n\t\t\t\t\t\t draggable: \".sortme\",\n\t\t\t\t onMove: function (evt) {\n\t\t\t\t return evt.related.className.indexOf('htmx-indicator') === -1;\n\t\t\t\t },\n\t\t\t\t onEnd: function (evt) {\n\t\t\t\t this.option(\"disabled\", true);\n\t\t\t\t }\n\t\t\t\t });\n\t\t\t\t // Re-enable sorting on the `htmx:afterSwap` event\n\t\t\t\t sortable.addEventListener(\"htmx:afterSwap\", function() {\n\t\t\t\t sortableInstance.option(\"disabled\", false);\n\t\t\t\t });\n\t\t\t\t }\n\t\t\t\t})\n\n\t\t\t\tfunction formValueChanged(fieldID, newValue) {\n\t\t\t\t\tvar formMetadata = JSON.parse(document.getElementById('form-metadata').getAttribute(\"data-data\"));\n\t\t\t\t\tif (formMetadata == null) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\t// collect the fields that have logic monitoring the changed field \n\t\t\t\t\tvar watchingFields = Object.values(formMetadata.form.fields).filter(function(field) {\n\t\t\t\t\t\treturn field.logic != null && fieldID === field.logic.target_field_id\n\t\t\t\t\t});\n\n\t\t\t\t\t// no fields watch the one that changed\n\t\t\t\t\tif (watchingFields.length == 0) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tvar fieldElement = document.getElementById(fieldID)\n\t\t\t\t\tfor (i in watchingFields) {\n\t\t\t\t\t\tlet watchingField = watchingFields[i]\n\t\t\t\t\t\tlet match = false\n\t\t\t\t\t\tvar watcherFieldContainerID = `field-container-${watchingField.id}` // the DOM element that contains the watching field\n\t\t\t\t\t\tlogic = watchingField.logic\n\n\t\t\t\t\t\t// check whether the new value is coming from a Choices.js field, in which case the new value\n\t\t\t\t\t\t// is the array of chosen values, joined by commas, otherwise newValue is used as it was passed in\n\t\t\t\t\t\tif (fieldElement != null && fieldElement._choices != null) {\n\t\t\t\t\t\t\t// Choics.getValue() returns scalar for single selects and array for multi. Use Array.of\n\t\t\t\t\t\t\t// to treat everything it returns as an array\n\t\t\t\t\t\t\tnewValue = Array.of(fieldElement._choices.getValue(true)).join(',')\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// find if _any_ trigger values match the new value\n\t\t\t\t\t\tswitch (logic.field_comparator) {\n\t\t\t\t\t\t\tcase 'equal':\n\t\t\t\t\t\t\t\tmatch = watchingField.logic.trigger_values.every(val => newValue.localeCompare(val, 'en', {sensitivity: \"base\"}) == 0)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'contains':\n\t\t\t\t\t\t\t\tmatch = watchingField.logic.trigger_values.some(val => newValue.toLowerCase().includes(val.toLowerCase()))\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Most actions are likely to be performed upon the containing element, such as show/hide/require.\n\t\t\t\t\t\t// This may of course change or be expanded, but for now, only the watcher field container is relevant\n\t\t\t\t\t\t// to applying actions.\n\t\t\t\t\t\tlet el = document.getElementById(watcherFieldContainerID)\n\t\t\t\t\t\tlet actions = watchingField.logic.actions\n\n\t\t\t\t\t\t// we have a match, execute the action\n\t\t\t\t\t\tfor (i in actions) {\n\t\t\t\t\t\t\tswitch (actions[i]) {\n\t\t\t\t\t\t\t\tcase \"field_logic_trigger_show\":\n\t\t\t\t\t\t\t\t\tif (match) {\n\t\t\t\t\t\t\t\t\t\tel.classList.remove(\"hidden\");\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tel.classList.add(\"hidden\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t</script>
</head>
<!doctype html><html lang=\"eng\">
<body class=\"\"><div id=\"errors\"></div><main hx-ext=\"response-targets\">
<body><main hx-ext=\"response-targets\">
</main>
</body></html>
<section id=\"app-container\">
@ -164,7 +164,8 @@ Multi select
\"
class=\"flex flex-col py-3 hidden\"
class=\"flex flex-col py-3\"
>
><div id=\"
\" class=\"text-red-400\"></div>
<input id=\"
\" name=\"
\" placeholder=\"

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

19
ui/errors.templ Normal file
View file

@ -0,0 +1,19 @@
package ui
import "fmt"
import "github.com/acaloiaro/frm/types"
// Validation checks which of a form's fields have validation errors and oob-swaps in error messages for fields that fail validation, and clear errors for fields that are valid
templ Validation(allFields []string, errs types.ValidationErrors) {
for _, fieldID := range allFields {
<div
id={ fmt.Sprintf("errors-%s", fieldID) }
data-hx-swap-oob="true"
class="text-red-400"
>
if verr, ok := errs[fieldID]; ok {
{ verr.Error() }
}
</div>
}
}

74
ui/errors_templ.go Normal file
View file

@ -0,0 +1,74 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.793
package ui
//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
import "fmt"
import "github.com/acaloiaro/frm/types"
// Validation checks which of a form's fields have validation errors and oob-swaps in error messages for fields that fail validation, and clear errors for fields that are valid
func Validation(allFields []string, errs types.ValidationErrors) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
if templ_7745c5c3_Var1 == nil {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
for _, fieldID := range allFields {
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("errors-%s", fieldID))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/errors.templ`, Line: 10, Col: 41}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if verr, ok := errs[fieldID]; ok {
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(verr.Error())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/errors.templ`, Line: 15, Col: 18}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
return templ_7745c5c3_Err
})
}
var _ = templruntime.GeneratedTemplate

3
ui/errors_templ.txt Normal file
View file

@ -0,0 +1,3 @@
<div id=\"
\" data-hx-swap-oob=\"true\" class=\"text-red-400\">
</div>