-
Notifications
You must be signed in to change notification settings - Fork 124
Description
System (please complete the following information):
- OS:
linux[e.g. linux, macOS] - GO Version:
1.25.0 - Pkg Version:
1.5.6
Describe the bug
I am trying to bind nested form data (e.g., address[city], address[street]) to a nested struct in a Goravel Form Request using multipart/form-data. While simple fields bind correctly, the nested fields are not being populated in the nested struct.
Steps to Reproduce:
Create a nested struct for the request:
type CreateMemberAddressRequest struct {
Street string `form:"street" json:"street"`
City string `form:"city" json:"city"`
}
type CreateMemberRequest struct {
Name string `form:"name" json:"name"`
Address CreateMemberAddressRequest `form:"address" json:"address"`
}
Send a POST request with Content-Type: multipart/form-data containing:
name: "John"
address[street]: "Main St"
address[city]: "New York"
Inspect the bound struct in the controller.
Expected Behavior: The
Address
struct should be populated with Street="Main St" and City="New York".
Actual Behavior: The
Address
struct is empty or nil. The ctx.Request().All() shows the keys as flat strings (e.g., "address[street]": "Main St") but they are not being mapped to the nested struct fields.
Environment:
Goravel Version: (Check your go.mod, e.g., v1.14.x)
Go Version: (e.g., 1.21)
OS: Mac/Linux/Windows
Additional Context: I have tried sending the data as address[street] and address.street, but neither seems to bind automatically to the nested struct when using multipart/form-data.