ReadForm binds the request body of a form to the "formObject". It supports any kind of type, including custom structs. It will return nothing if request data are empty. The struct field tag is "form". Note that it will return nil error on empty form data if `Configuration.FireEmptyFormError` is fals
(formObject interface{})
| 2968 | // |
| 2969 | // Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-form/main.go |
| 2970 | func (ctx *Context) ReadForm(formObject interface{}) error { |
| 2971 | values := ctx.FormValues() |
| 2972 | if len(values) == 0 { |
| 2973 | if ctx.app.ConfigurationReadOnly().GetFireEmptyFormError() { |
| 2974 | return ErrEmptyForm |
| 2975 | } |
| 2976 | return nil |
| 2977 | } |
| 2978 | |
| 2979 | err := schema.DecodeForm(values, formObject) |
| 2980 | if err != nil && !IsErrPathCRSFToken(err) { |
| 2981 | return err |
| 2982 | } |
| 2983 | |
| 2984 | return ctx.app.Validate(formObject) |
| 2985 | } |
| 2986 | |
| 2987 | type ( |
| 2988 | // MultipartRelated is the result of the context.ReadMultipartRelated method. |
no test coverage detected