GX3007: route type has two key fields, or a key field that cannot bind
Two fields of a route type have the tag gx:"key", or the key field is not a bound field of a basic type.
Cause
The key field of a route type has the tag gx:"key". Its value goes into the id of the form and of each field. A route type has one key field at most. The key field is a bound field of a basic type, such as string or int, so a failed submit binds the same key.
gx generate fails when two fields have the tag. It also fails when the field with the tag is a slice, a struct, a file or a field with bind:"-".
Example
package route
import "github.com/alternayte/gx"
type Revoke struct {
gx.Route `POST /sessions/revoke`
ID string `gx:"key"`
Device string `gx:"key"`
}
func (in *Revoke) Rules() gx.Rules {
return gx.Rules{gx.Field(&in.ID, gx.Required)}
}gx check reports:
sessions/route/route.go:8:2: GX3007: route type "Revoke" has two key fields: "ID" and "Device"Fix
- Keep the tag
gx:"key"on one field. - Use a field whose value is different for each form of the page.