0.11.9 : add create event and field changes
This commit is contained in:
@@ -23,9 +23,27 @@ export default ({ strapi }: { strapi: Core.Strapi }) =>
|
||||
}
|
||||
|
||||
try {
|
||||
// Format tags from array of strings to array of component objects
|
||||
const data = ctx.request.body.data;
|
||||
if (data.tags && Array.isArray(data.tags)) {
|
||||
data.tags = data.tags
|
||||
.filter((tag: any) => {
|
||||
// Skip if already formatted as object, or if it's null/empty
|
||||
if (typeof tag === "object") return true;
|
||||
return tag && String(tag).trim().length > 0;
|
||||
})
|
||||
.map((tag: any) => {
|
||||
// Convert string tags to component format
|
||||
if (typeof tag === "string") {
|
||||
return { tag: tag.trim() };
|
||||
}
|
||||
return tag;
|
||||
});
|
||||
}
|
||||
|
||||
// 1. Call the default Strapi create method
|
||||
const event = await strapi.entityService.create("api::event.event", {
|
||||
data: ctx.request.body.data,
|
||||
data,
|
||||
});
|
||||
|
||||
if (!event) {
|
||||
|
||||
Reference in New Issue
Block a user