Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to derive Linked Entries when field type is a list? #1249

Open
daviddelusenet opened this issue Sep 7, 2023 · 3 comments
Open

How to derive Linked Entries when field type is a list? #1249

daviddelusenet opened this issue Sep 7, 2023 · 3 comments

Comments

@daviddelusenet
Copy link

I'm running basically into the same issue as in #158.

I got a content model called Radio which currently has a field called options which is of the type Short text, list. The values of this field for example are: ['Option 1', 'Option 2', 'Option 3'].

Now I want to write a migration which migrates every value in the options field array to an entry, so this should be the end result:

// Entry 1
{
  key: "Option 1",
  label: "Option 1
}

// Entry 2
{
  key: "Option 2",
  label: "Option 2"
}

// Entry 3
{
  key: "Option 3",
  label: "Option 3"
}

However, the deriveLinkedEntries will only run once for the options field but this field contains multiple values.

Can you provide an example of a migration which converts each value of a list field to an entry?

Please let me know if you need any more information and thanks in advance.

@neptunus
Copy link
Contributor

I'm dealing with exactly the same problem.
@daviddelusenet did you ever find a solution?

@zachcd
Copy link

zachcd commented Jan 31, 2024

I'm also running into this issue.

We'd prefer to stick with migrations rather than using the CMA if it's at all possible.

@Ranguna
Copy link

Ranguna commented Jun 13, 2024

Having the ability to return an array of objects instead of just one object would be great.

For reference this is what I'd like to do:

Original entry:

{
  "list":[
    "option 1",
    "option 2",
    "option 3"
  ]
}

To this new object:

{
  "list_ref": [ref1, ref2, ref3]
}

// on a different content type
// ref1:
{
  "title": "option 1"
}
// ref2:
{
  "title": "option 2"
}
// ref3:
{
  "title": "option 3"
}

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

No branches or pull requests

4 participants