flattenFields doesn't work if field with sub-fields has a Name

default discord avatar
HoneySpace
8 months ago
1 1

Bug Report

If collection config have fields with type:

  • array
  • row
  • group
  • collapsible

And they have a name, flattenFields will skip sub-fields

Steps to Reproduce

  1. Create a colection config with array or group field
  2. Add name to the field
  3. Check the result of flattenFields

Other Details

Caused by this check, it'd be better to first check if field have a sub-fields despite having a name, then if it doesn't check for a name and return new array

  • discord user avatar
    jmikrut
    Payload Team
    8 months ago

    Hey @HoneySpace — this is actually working as intended, although the function could be misleading. It does not flatten ALL fields, it only flattens the fields that exist within a non-named field.

    What are you looking to do? Can I help? Gonna convert this to a discussion to keep it going.

    1 reply
  • default discord avatar
    HoneySpace
    7 months ago

    Well, I was actualy trying to extend search cappabilities, since Payload API supporst search in nested fields, all I needed was to change how fields get seleceted for building query

    I changed flatten fucntion so it flatten all fields and added extra function to crawl through first-level fields to add collection fields to relationship fields
    Now I have very flexable search controled just by listSearchableFields

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.