Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

issue when publish #44

Open
loveleet-convivity opened this issue Sep 26, 2023 · 0 comments
Open

issue when publish #44

loveleet-convivity opened this issue Sep 26, 2023 · 0 comments

Comments

@loveleet-convivity
Copy link

Screen.Recording.2023-09-26.at.1.39.22.PM.mov

i have uploaded the video to related issue

issue:
when i chose category item, then there are 2 sub categories item and then i select one and publish , but after i change the item of category and then chose the same item, its corresponding subitems are not showing all items.

import { CollectionConfig } from "payload/types";
import Fields from "./common/fields";

const Courses: CollectionConfig = {
  slug: "courses",
  admin: {
    useAsTitle: "name",
  },
  fields: [
    {
      type: "tabs",
      tabs: [
        {
          label: "Basic",
          description: "asa",
          fields: [
            {
              type: "text",
              name: "title",
              required: true,
            },
            {
              type: "textarea",
              name: "excerpt",
              required: true,
            },
            {
              type: "richText",
              name: "content",
              required: true,
            },
            {
              type: "relationship",
              relationTo: "videos",
              name: "previewVideo",
              required: true,
            },
            {
              type: "upload",
              relationTo: "media",
              name: "image",
              required: true,
            },
            {
              name: "materials",
              type: "array",
              fields: [
                {
                  name: "item",
                  type: "upload",
                  relationTo: "media",
                  required: true,
                },
              ],
            },
          ],
        },
        {
          label: "Builder",
          description: "Build your Course",
          fields: [
            {
              name: "lessons",
              type: "relationship",
              label: "Lessons",
              relationTo:"lessons",
              hasMany:true,
            },
          ],
        },
        {
          label: "Settings",
          description: "setting related to course",
          fields: [
            {
              name: "quizCategories",
              label: "Quiz Categories",
              type: "array",
              fields: [
                {
                  type: "relationship",
                  relationTo: "categoriesitem",
                  name: "categoriesItem",
                },
                {
                  type: "relationship",
                  relationTo: "categoriessubitem",
                  name: "categoriesSubItem",
                  hasMany: true,
                  filterOptions: ({ data, siblingData }: any) => {
                    if (siblingData?.categoriesItem) {
                      return {
                        parent: { equals: siblingData?.categoriesItem },
                      };
                    }
                  },
                },
              ],
            },
          ],
        },
      ],
    },
  ],
  versions: {
    drafts: {
      autosave: true,
    },
  },
};

export default Courses;

Expected Behaviour:
sub categories items will work properly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant