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

Default value #16

Closed
matteocattelan opened this issue Sep 1, 2023 · 3 comments
Closed

Default value #16

matteocattelan opened this issue Sep 1, 2023 · 3 comments

Comments

@matteocattelan
Copy link

Hi,
is possible for required field set a default value?

Thanks a lot. Great Job!!

@matteocattelan
Copy link
Author

I found the solution:

strapi-plugin-multi-select/admin/src/components/MultiSelect/index.js
const sanitizedValue = useMemo(() => { let parsedValue try { parsedValue = JSON.parse(value || attribute['default']) } catch (e) { parsedValue = [] } return Array.isArray(parsedValue) ? possibleOptions.filter((option) => parsedValue.some((val) => option.value === val), ) : [] }, [value, possibleOptions])

in json of configuration can use this:

"options": [ "A:a", "B:b", "C": c" ], "required": true, "default": ["a"],

Is possibile include this code in the distribution?
Thanks

@FlashThePlayer
Copy link

FlashThePlayer commented Oct 5, 2023

@Zaydme ping?
Would be amazing to have this feature

Edit:
I also created a pull request, if its fine a merge would be amazing
#19

@Zaydme
Copy link
Owner

Zaydme commented Oct 10, 2024

closed in 073af31
available in @2.1.0

@Zaydme Zaydme closed this as completed Oct 10, 2024
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