#Customize Array Naming Based on Single Field?

1 messages · Page 1 of 1 (latest)

rotund ridgeBOT
#

Is there any setting that I can customize the naming of the array based on a single field? As you see the Variant 01 to default

torn notchBOT
#

Original message from @lilac peak - Moved from #general message

meager shard
#

@lilac peak Like this?

      admin: {
        components: {
          RowLabel: ({ data, index }: RowLabelArgs) => {
            return data?.title || `Slide ${String(index).padStart(2, '0')}`
          },
        },
      },
#

Data I believe has the field values in the array

lilac peak
#

Let me give it a try.

meager shard
#

Function or React component to be rendered as the label on the array row. Receives ({ data, index, path }) as args

lilac peak
#

For some reason, the example code does not work.

#

data, index, and path are undefined

meager shard
#

how did you add it to your collection?

lilac peak
#
{
              name: 'variant',
              type: 'array',
              label: false,
              required: true,
              validate: validateVariant,
              admin: {
                components: {
                  RowLabel: ({data}) => data?.name || 'New Variant' // TODO: Fix data undefined issue. 
                }
              },
              fields: [
                {
                  type: 'row',
                  fields: [
                    {
                      name: 'name',
                      type: 'text',
                      required: true,
                    }
                  ]
                },
                {
                  type: 'row',
                  fields: [
                    {
                      name: 'stripeProductId',
                      type: 'text',
                    }
                  ]
                }

              ],
              minRows: 1,
              labels: {
                singular: 'Variant',
                plural: 'Variants',
              }
            }
past shell
#

I have the same issue

lilac peak
#

It looks like this is a known issue and has not been fixed yet.