support radio buttons
This commit is contained in:
@@ -109,12 +109,12 @@ func (wc *WebController) adminAbuseForm(td *TemplateData, r *http.Request) (f Fo
|
||||
Name: "type",
|
||||
Label: "Type",
|
||||
DefaultValue: "unknown",
|
||||
Description: "Can be 'unknown', 'copyright', 'terrorism' or 'child_abuse'",
|
||||
Type: FieldTypeText,
|
||||
Type: FieldTypeRadio,
|
||||
RadioValues: []string{"unknown", "copyright", "terrorism", "child_abuse"},
|
||||
}, {
|
||||
Name: "reporter",
|
||||
Label: "Reporter",
|
||||
DefaultValue: "pixeldrain",
|
||||
DefaultValue: "Anonymous tip",
|
||||
Type: FieldTypeText,
|
||||
},
|
||||
},
|
||||
|
@@ -60,6 +60,9 @@ type Field struct {
|
||||
|
||||
// Only used when Type == FieldTypeCaptcha
|
||||
CaptchaSiteKey string
|
||||
|
||||
// Only used when Type == FieldTypeRadio
|
||||
RadioValues []string
|
||||
}
|
||||
|
||||
// ExtraActions contains extra actions to performs when rendering the form
|
||||
@@ -84,6 +87,7 @@ const (
|
||||
FieldTypeNumber FieldType = "number"
|
||||
FieldTypeUsername FieldType = "username"
|
||||
FieldTypeEmail FieldType = "email"
|
||||
FieldTypeRadio FieldType = "radio"
|
||||
FieldTypeCurrentPassword FieldType = "current-password"
|
||||
FieldTypeNewPassword FieldType = "new-password"
|
||||
FieldTypeCaptcha FieldType = "captcha"
|
||||
@@ -103,7 +107,7 @@ func (f *Form) ReadInput(r *http.Request) (success bool) {
|
||||
// Remove carriage returns
|
||||
field.EnteredValue = strings.ReplaceAll(r.FormValue(field.Name), "\r", "")
|
||||
|
||||
if field.DefaultValue == "" {
|
||||
if field.EnteredValue != "" {
|
||||
field.DefaultValue = field.EnteredValue
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user