#How to set group to optional?

6 messages · Page 1 of 1 (latest)

wanton tapir
#

Hello, I have a group called "home" and in my mongodb database this field can be null or a json object with some fields. When I enter my listing it gives an error in the console with the following message:

ERROR (payload): TypeError: Cannot read properties of null (reading 'show')

slim fableBOT
wanton tapir
#

@tribal relic you can help me?

glossy isle
#

Can you share your code please?

wanton tapir
#

@glossy isle this is my code, field group called "home" is possibly null on database

const CelebrityRooms: CollectionConfig = {
  slug: 'c_celebrityroom',
  admin: {
    defaultColumns: ['id', 'name'],
    useAsTitle: 'name',
    group: 'Site',
  },
  fields: [
    {
      type: 'tabs',
      tabs: [
        {
          label: 'Home',
          fields: [
            {
              label: 'Informações da home',
              name: 'home',
              type: 'group',
              fields: [
                {
                  label: 'Exibir na home',
                  name: 'show',
                  type: 'checkbox',
                  required: false,
                },
                {
                  label: 'Nome',
                  name: 'name',
                  type: 'text',
                  required: false,
                },
                {
                  label: 'Descrição',
                  name: 'description',
                  type: 'textarea',
                  required: false,
                },
                {
                  label: 'Icone',
                  name: 'icon',
                  type: 'text',
                  required: false,
                },
              ],
            },
          ],
        },
      ],
    },
  ],
}

export default CelebrityRooms
glossy isle
#

I wouldnt if that is a remnant from a previous structure of this data