-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to prevent binding of a particular struct field? #1631
Comments
Just dont include the ID inside the type. |
Please see my comment |
Now the DefaultBinder could be configured to avoid binding struct fields by name. This is particularly useful when the user don't want to bind certain struct fields (with this config in true, only the tagged fields will be binded) Fixes labstack#1620, fixes labstack#1631, partially fixes labstack#1670
No more comments from the reporter of the ticket. Closing. |
how can we prevent bind function to bind some form fields to the struct fields?
For example
type student struct{
ID int form:"-"
Name string form:"name"
Details string form:"details"
}
Here i do not want bind function in echo to bind id from the create student request to ID. but if i post like. -:1 name:student details:student
it will bind - value to ID which i do not want.
And if i skip form tag as shown below
type student struct{
ID int
Name string form:"name"
Details string form:"details"
}
then do a post request
id:1 name:student details:student
now the bind function will bind id with ID.
the problem is I am not able to skip binding for ID field
The text was updated successfully, but these errors were encountered: