Skip to content
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

Select field type should accept an array of objects #3

Open
sjstark opened this issue Jan 21, 2022 · 3 comments
Open

Select field type should accept an array of objects #3

sjstark opened this issue Jan 21, 2022 · 3 comments

Comments

@sjstark
Copy link
Member

sjstark commented Jan 21, 2022

Should be able to set options prop to an array of {'label','value'} POJOs

@weotch
Copy link
Member

weotch commented Jan 21, 2022

That certainly makes sense to me ... it looks like it's expecting an array of strings right now? @jonjahr what does this regex do?

arr = option?.split?(/(?:\s)+(?:\|)+(?:\s)+/)

Like what is an example of an expected string value of an option currently?

Maybe, to preserve backwards compatibility, we can typeof check the value of an option and if string do the regex thing else if object, expect one with a structure like @sjstark's suggestion.

@jonjahr
Copy link
Contributor

jonjahr commented Jan 21, 2022

Yes this makes sense to me too. The regex I’m pretty sure tries to parse a label-value pair from the string with a pipe separator, ie “Layout Left | layout-left”. I’d like to keep the string option for back compatibility at least for a little while until I know for sure the POJO route is easy to work with in Contentful.

@weotch
Copy link
Member

weotch commented Jan 22, 2022

Ahhh, it's like that for Contentful, gotcha.

Btw, did you guys just learn about POJO recently? Cause I did. 🤓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants