GX2024: password input with a value
An input of type password has a value attribute, or spreads the attributes of a form field.
Cause
An <input type="password"> has a value attribute, or it spreads the attributes of a form field, which hold the value. The render never writes the value of a password input. A password does not come back in the HTML after a failed submit, in a patch or in a cache.
The finding is a hint. It does not fail gx check. It tells you that the value of the template has no effect.
Example
package route
import "github.com/alternayte/gx"
type SignIn struct {
gx.Route `POST /signin`
Password string
}
func (in *SignIn) Rules() gx.Rules {
return gx.Rules{gx.Field(&in.Password, gx.Required)}
}package auth
import "app/auth/route"
props {
F route.SignInForm
}
<form {...p.F.Attrs()}>
<label for={p.F.Password.ID}>Password</label>
<input {...p.F.Password.Attrs()} type="password" />
<button type="submit">Sign in</button>
</form>gx check reports:
auth/SignIn.gx:11:10: GX2024: hint: an input of type password gets no value: the render drops the value of the attribute or of the spreadFix
Remove a value attribute. The spread of a form field still gives the input its name, its id and its aria state, so you can keep it. After a failed submit, the reader types the password again.