Open drweizak opened 2 months ago
Hello everyone! I am trying to create a custom preview! This is one of my fields in my collection
{ label: "Secções", label_singular: "Secção", name: "sections", widget: "list", summary: "{{fields.name}}", types: [coverLayout, blankSectionLayout], },
In my preview template I have the following code:
const PostPreview: FC<TemplatePreviewProps<IPost>> = ({ entry, widgetFor, widgetsFor, }) => { if (entry?.data?.type === "publication") { const { title } = entry.data; return ( <div> {widgetsFor("sections").map((section, index) => section ? ( <div key={index}> <hr /> <strong>{section.data?.title}</strong> </div> ) : null )} </div> );
I am getting the following error: Uncaught TypeError: widgetsFor(...).map is not a function
My interface:
export default interface IPost { id: UUID; slug: string; type: IPostType; pre_title?: string; title: string; sub_title?: string; description?: string; publish_date: string; sections: ISection[]; authors: IAuthor["slug"][]; category: ICategory["slug"]; tags: ITag["slug"][]; }
I have tried different approaches. I have data on my section when i log the data.sections. I found out that it's because i am using types instead of fields
Is there a way to use widgetsFor for a typed List?
Hello everyone! I am trying to create a custom preview! This is one of my fields in my collection
In my preview template I have the following code:
I am getting the following error: Uncaught TypeError: widgetsFor(...).map is not a function
My interface:
I have tried different approaches. I have data on my section when i log the data.sections. I found out that it's because i am using types instead of fields
Is there a way to use widgetsFor for a typed List?