strapi-plugin-multi-enum-select
A strapi custom field for selecting multiple Enum options from a provided list of items
Strapi plugin multi-enum-select
A strapi custom field for selecting multiple Enum options from a provided list of items
- Forked from (https://github.com/Zaydme/strapi-plugin-multi-select) and make it with a string type instead of json for filtering
Installation
To install this plugin, you need to add an NPM dependency to your Strapi application:
# Using Yarn
yarn add strapi-plugin-multi-enum-select
# Or using NPM
npm install strapi-plugin-multi-enum-selectThen, you'll need to build your admin panel:
# Using Yarn
yarn build
# Or using NPM
npm run buildUsage
After installation you will find the multi-enum-select at the custom fields section of the content-type builder.
You add options to the multi-enum-select by adding a line separated list of options to the options field.
You can also add a value and a label separated by a colon (e.g. label:value). If no value is provided, the label will be used as the value.
then you can select one or more options from the list.
in this case the API will return
{
"data": {
"id": 1,
"stuff": "Banana,citron"
}
}where you can filter it with $eq or $contains or .etc
and you can parse it with:
const values = stuff.split(',');Delimiter
You can configure which character is used to separate the stored values. The delimiter is set per field in the Base settings tab of the content-type builder.
Available options:
| Label | Character |
|---|---|
Comma , (default) | , |
Semicolon ; | ; |
Pipe \| | \| |
Slash / | / |
Dash - | - |
When a non-default delimiter is configured the API response will reflect it:
{
"data": {
"id": 1,
"stuff": "Banana;citron"
}
}Parse it on the client with the matching delimiter:
const delimiter = ';'; // match what you set in the field settings
const values = stuff.split(delimiter);Note: If you change the delimiter on an existing field, previously stored values will not be migrated automatically. Make sure to update your stored data accordingly.
why it's better than the original plugin
1- string types are faster for data retrieving ond have hiegher performance
2- now you can filter the results with the fields you've created
3- so simple to sanitize the data to array again
Thanks for installing
here is the original plugin: https://github.com/Zaydme/strapi-plugin-multi-select
You can also check the multi-country-select plugin
Install now
npm install strapi-plugin-multi-enum-select
Create your own plugin
Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.