Skip to content

Plugin not working with new database #85

@gonzamoiguer

Description

@gonzamoiguer

I was using this plugin (slug field specifically) in development with an already initialized payload. Worked fine. When deployed to an empty project it threw an error. Reproduced with empty project.
Steps to reproduce

  1. Start new payload project npx create-payload-app@latest
  2. Add better fields yarn add @nouance/payload-better-fields-plugin
  3. Add slug field to users collection
import { CollectionConfig } from 'payload/types'
import { SlugField } from '@nouance/payload-better-fields-plugin'

const Users: CollectionConfig = {
  slug: 'users',
  auth: true,
  admin: {
    useAsTitle: 'email',
  },
  fields: [
    {
      name: 'title',
      type: 'text',
    },
    ...SlugField(
      {
        name: 'slug',
        admin: {
          position: 'sidebar',
        },
      },
      {
        useFields: ['title', 'subtitle'],
      },
    ),
  ],
}

export default Users
  1. Run docker docker-compose up and open localhost:3000

Error reports Component.js:78 Uncaught TypeError: Cannot read properties of undefined (reading 'value') pointing to this line return fields .filter(function (item) { return Boolean(item.value); })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions