mirror of
https://github.com/therootcompany/golib.git
synced 2026-04-24 20:58:00 +00:00
fix: FormFields defaults to GravityForms-compatible input_N names
This commit is contained in:
parent
d57c810c2e
commit
225faec549
@ -67,13 +67,13 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// FormFields maps logical field names to the HTML form field names.
|
// FormFields maps logical field names to the HTML form field names.
|
||||||
// Zero values fall back to the field name itself ("name", "email", etc.).
|
// Zero values use GravityForms-compatible defaults (input_1, input_3, etc.).
|
||||||
type FormFields struct {
|
type FormFields struct {
|
||||||
Name string // default "name"
|
Name string // default "input_1"
|
||||||
Email string // default "email"
|
Email string // default "input_3"
|
||||||
Phone string // default "phone"
|
Phone string // default "input_4"
|
||||||
Company string // default "company"
|
Company string // default "input_5"
|
||||||
Message string // default "message"
|
Message string // default "input_7"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FormFields) get(r *http.Request, field, def string) string {
|
func (f FormFields) get(r *http.Request, field, def string) string {
|
||||||
@ -177,11 +177,11 @@ func (fm *FormMailer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
name := fm.Fields.get(r, fm.Fields.Name, "name")
|
name := fm.Fields.get(r, fm.Fields.Name, "input_1")
|
||||||
email := strings.ToLower(fm.Fields.get(r, fm.Fields.Email, "email"))
|
email := strings.ToLower(fm.Fields.get(r, fm.Fields.Email, "input_3"))
|
||||||
phone := fm.Fields.get(r, fm.Fields.Phone, "phone")
|
phone := fm.Fields.get(r, fm.Fields.Phone, "input_4")
|
||||||
company := fm.Fields.get(r, fm.Fields.Company, "company")
|
company := fm.Fields.get(r, fm.Fields.Company, "input_5")
|
||||||
message := fm.Fields.get(r, fm.Fields.Message, "message")
|
message := fm.Fields.get(r, fm.Fields.Message, "input_7")
|
||||||
|
|
||||||
if err := validateLengths(name, email, phone, company, message); err != nil {
|
if err := validateLengths(name, email, phone, company, message); err != nil {
|
||||||
fm.writeError(w, err, true)
|
fm.writeError(w, err, true)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user