Enhance checkbox-list custom field functionality
- Added CheckboxListEnumInput component for handling enumeration inputs. - Updated CheckboxListDefaultInput to support new options structure. - Integrated validation for checkbox list options using Yup. - Modified package.json and package-lock.json to include new dependencies. - Improved admin interface with enhanced input handling and validation feedback.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { EnumerationField } from '@strapi/icons/symbols';
|
||||
import { CheckboxListEnumInput } from './components/CheckboxListEnumInput';
|
||||
import { Initializer } from './components/Initializer';
|
||||
import { CheckboxListDefaultInput } from './components/CheckboxListDefaultInput';
|
||||
import { PLUGIN_ID } from './pluginId';
|
||||
import { checkboxListOptionsValidator } from './utils/checkboxListValidator';
|
||||
|
||||
export default {
|
||||
register(app: any) {
|
||||
@@ -19,6 +21,10 @@ export default {
|
||||
id: 'checkbox-list-default',
|
||||
component: CheckboxListDefaultInput,
|
||||
});
|
||||
ctbPlugin.apis.forms.components.add({
|
||||
id: 'checkbox-list-enum',
|
||||
component: CheckboxListEnumInput,
|
||||
});
|
||||
}
|
||||
|
||||
app.customFields.register({
|
||||
@@ -47,8 +53,8 @@ export default {
|
||||
sectionTitle: null,
|
||||
items: [
|
||||
{
|
||||
name: 'enum',
|
||||
type: 'textarea-enum',
|
||||
name: 'options.enum',
|
||||
type: 'checkbox-list-enum',
|
||||
size: 6,
|
||||
intlLabel: {
|
||||
id: 'form.attribute.item.enumeration.rules',
|
||||
@@ -58,6 +64,7 @@ export default {
|
||||
id: 'form.attribute.item.enumeration.placeholder',
|
||||
defaultMessage: 'Ex:\nmorning\nnoon\nevening',
|
||||
},
|
||||
defaultValue: [],
|
||||
validations: {
|
||||
required: true,
|
||||
},
|
||||
@@ -128,6 +135,7 @@ export default {
|
||||
],
|
||||
},
|
||||
],
|
||||
validator: checkboxListOptionsValidator,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user