Dynamic select field

Hello everyone,
I would like to know if it is possible to create a dynamic select field.

That is that it is populated from another part which is not a collection.

Example:
I would like to create a “General Settings” singleton with all the settings inside.
Including a repeater for my dynamic Select.

Thanks in advance

I think, you are looking for this one:

I took a quick look.
I don’t know if that’s what I’m looking for.

As written I need that the select is populated by a repeater field that is inside a singleton.

This abdomen seems to me to have understood that it takes from a collection. And I don’t need to create a collection.

Maybe I misunderstood.
Is it possible to give me an example of my problem?

Singleton: generalsettings

Inside I have the repeater: job_position

-> manager
-> employee
-> other …

@raffaelj
Collection: team

here I would like to have the select with inside:
-> manager
-> employee
-> other …

I hope I have described everything well

I think, I’ll have more time on Tuesday to look at your issue. I’m still moving from Windows to Linux, migrating data and trying to rebuilt by development setup… If I forget about it, answer here and mention my name, so I’ll get a mail notification.

You need to do multiple steps:

  1. Your select field needs to be able to get dynamic options instead of static ones.
  2. The select field needs to know, where to get these options.
  3. If where doesn’t exist, you have to define it.

I wrote the SelectRequestOptions addon in the past to solve 1. and 2. and also to have some options for pretty rendering.

For 3., you have to write your own admin ui endpoint, that delivers your data.

/config/bootstrap.php:

$app->on('admin.init', function() {
    $this->bind('/custom', function() {
        $data = $this->module('singletons')->getData('generalsettings');
        $positions = $data['job_position'];
        // maybe you have to reformat this data so it matches the select options format
        return $positions;
    });
});

Now you can call https://cockpiturl.com/custom while you are logged in and you have a pretty json string of your singleton field.

Now you could build your own select field that requests your custom route and displays the options or you use my addon, where I did that step for you already.

1 Like

Thanks.
Now I do some tests to check the operation.

Thanks again for the availability

Is it possible to transform the radio field into a select field?

No, I only implemented radio buttons and a switch to display a tags field or a color field in the SelectRequestOptions addon. When I wrote that addon, my use case was to have select fields for categories and colors, that are defined in a different collection.

1 Like

I have a question about this SelectRequestOptions…
I crate a collection to put ingredients and i would like to create a multiple select on my product collection and take more than one ingredient, im trying something like this:

{
“request”: “/api/collections/find”,
“key”: “collection”,
“options”:{
“token”:“mytoken”
},
“value”: “_id”,
“label”: “name”,
“multiple”: true
}

but i dont recive nothing =(

Given the plugins documentation the request path is not supposed to contain the /api part but in your example be

“request”: “/collections/find”,