form
form copied to clipboard
reflect.Value.Interface: cannot return value obtained from unexported field or method
Hi,
I'm trying to use your librayr to generate a form for Config struct.
I get this error I don't quite know how to debug yet:
template: manage:10:18: executing "content" at <inputs_for .Config>: error calling inputs_for: reflect.Value.Interface: cannot return value obtained from unexported field or method
Here is what I'm trying to generate a form for:
https://github.com/prologic/twtxt/blob/75cccfa29e6c31980fb98ee1e3772207a0fda28c/internal/config.go#L15
Thanks!
the only two unexported fields in the Config struct (the lower case ones) are the baseURL and whiteListedDomains, make them uppercase and it should work. Ivan S Kirkpatrick, PE [email protected], 850 778 2139 Tessaract Inc. http://www.tessaract.net 415 580 2139
On Wed, Aug 12, 2020 at 4:36 AM James Mills [email protected] wrote:
Hi,
I'm trying to use your librayr to generate a form for Config struct.
I get this error I don't quite know how to debug yet:
template: manage:10:18: executing "content" at <inputs_for .Config>: error calling inputs_for: reflect.Value.Interface: cannot return value obtained from unexported field or method
Here is what I'm trying to generate a form for:
https://github.com/prologic/twtxt/blob/75cccfa29e6c31980fb98ee1e3772207a0fda28c/internal/config.go#L15
Thanks!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joncalhoun/form/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGGPTVQHB3TORMP2XHVX74TSAJH75ANCNFSM4P4KN7KA .
Those two fields are deliberately not exported. I kind of expected your library to ignore them? Also FWIW I decided in the end against using your library here to generate forms as the end result wasn't that great. I'm instead just opting for just a large textarea and allowing the user to edit the config as YAML. Sorry :/ I was hoping this library would generate checkboxes for booleans, dropdowns for choices and some way of handling slices. 🤷♂️
The library currently only supports what I needed when I built it. It certainly could support checkboxes and other similar features, and some of those could be handled with a custom template too, but it doesn't currently.
The unexported fields bit is a bug.
Hit the wrong button on mobile. Sorry. Reopening.
No worries :) Thanks!