How to: set input filed of one model (section model) to a content from another model (data model)

Hello, i have a question regarding the builder io visual editor.

So, i have a section model called blog with slug of type text and enumPosts of type select.

This section model uses dynamic preview url like this:

And then i have another data model (NOT section model) looking like that:

What i want is to be able from the visual editor to get all the posts, iterate over them and create array of all posts’ slugs and set the blog’s enum posts field to be equal to all the posts’ slugs.

I want to achieve this from the builder.io editor so that i can use the enum value as slugs instead of having a slug input filed of type text i want to have enum posts filed of type enum and use the selected post as slug for the dynamic preview url here:

Is this possible at all ?

Hello @Mehan,

To achieve this, you’ll want to programmatically generate the list of post slugs from your data model and update the enumPosts field in your blog section model. Here is a step-by-step guide to accomplish this:

  1. Retrieve all the post slugs from the data model.
  2. Transform the slugs into an array suitable for the enumPosts field.
  3. Update the enumPosts field in the blog section model in the Builder.io Visual Editor.

You need to fetch all the posts from your data model and extract their slugs. Use Builder’s Content API for this. Transform the slugs into an array of options suitable for the enumPosts field.
You will then populate the enumPosts field in the blog section model with the generated slugs.

You can possibly perform this operation while generating the dynamic preview URL.

Hope this helps!