form icon indicating copy to clipboard operation
form copied to clipboard

reflect.Value.Interface: cannot return value obtained from unexported field or method

Open prologic opened this issue 5 years ago • 5 comments

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!

prologic avatar Aug 12 '20 08:08 prologic

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 .

ivank2139 avatar Aug 12 '20 16:08 ivank2139

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. 🤷‍♂️

prologic avatar Aug 13 '20 10:08 prologic

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.

joncalhoun avatar Aug 15 '20 15:08 joncalhoun

Hit the wrong button on mobile. Sorry. Reopening.

joncalhoun avatar Aug 15 '20 15:08 joncalhoun

No worries :) Thanks!

prologic avatar Aug 19 '20 05:08 prologic