Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX sql 1.7.1 bug #588

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix sql 1.7.1 setOptionsFromSQL []uint8 bug
  • Loading branch information
Mojito-source committed Aug 24, 2023
commit 04235e1ec8a6424fff6169f0aeb876d97652572e
18 changes: 14 additions & 4 deletions template/types/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"html"
"html/template"
"net/http"
"reflect"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -209,10 +210,19 @@ func (f *FormField) setOptionsFromSQL(sql *db.SQL) {
queryRes, err := sql.All()
if err == nil {
for _, item := range queryRes {
f.Options = append(f.Options, FieldOption{
Value: fmt.Sprintf("%v", item[f.OptionTable.ValueField]),
Text: fmt.Sprintf("%v", item[f.OptionTable.TextField]),
})
value := item[f.OptionTable.ValueField]
typeStr := reflect.TypeOf(value).String()
if typeStr == "[]uint8" {
f.Options = append(f.Options, FieldOption{
Value: fmt.Sprintf("%v", string(value.([]uint8))),
Text: fmt.Sprintf("%v", item[f.OptionTable.TextField]),
})
} else {
f.Options = append(f.Options, FieldOption{
Value: fmt.Sprintf("%v", value),
Text: fmt.Sprintf("%v", item[f.OptionTable.TextField]),
})
}
}
}

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy