AdminUI: Is there any dynamic/custom List/Array Property Editor for adding a list of strings?

Hi,

I would like to add a list of strings/texts to populate a select element in a form in the Backend Admin UI. With this the editor person could easily add his custom select option elements. But as far as I have seen the SelectBoxEditor Property Editor Reference — Neos CMS 7.3.x documentation only allows a fixed set of entries.

Can this use case be achieved by Neos out of the Box or is some custom Property Editor needed for this? I have tried for example just to set the “type: array” for my property in the NodeType definition, but this did not work of course :slight_smile: .

Another idea could be to just simply provide an input textfield and the Editor needs to add comma-separated values to the field and in the Fusion I could split this string into an array and use it for the rendering of the select element, but haven’t tried it out yet.

What would be your recommendations?

Thank you for your inputs!

Jup as you highlighted already The data for populating the select box can be fetched from a fixed set of entries defined in YAML or a datasource.

So using a textbox and split on , is the only out of the box way i see too. You can of course also create a new editor that would allow setting user values.

A tag or keyword cloud editor would come in handy… maybe there is more demand ^^

I’ve read your requirements several times but I’m not sure if I fully understand your requirements. When writing about “in a form”, are we talking about a Form Framework (Form Builder etc.) form?

Depending on your exact requirements, a Data Source could help you. But maybe if you could specify more clearly or even add a mockup/screenshot, this would help helping you.

The use case is that an Editor/Author person would like to define the option elements in a HTML select element by himself instead that the Developer pre-defines these option elements. I use the Neos Fusion Form package for this custom form. And now I as a Developer would like to provide some possibility for the Editor/Author user that he/she can edit the option elements in a select form element by themselves. Using a DataSource for the select element does not fully solve yet the requirement because you still need then somwhere some “tool” where the Editor/Author can edit these select option values.

That’s why my question was if there is already such a possibility where you actually have this Neos SelectBox Property Editor but with the functionality to add custom strings in an array/list instead to predefine this list via hardcoded strings in the NodeType definition file or via DataSource configuration.

Hope it is a bit more clear?

I have solved it now temporarily by using simply a textarea Property Editor in the AdminUI with the convention for the Editor/Author that he/she should add values separated by a comma. This string will then be split by the comma and with this we also receive the array of these string values for using an Fusion Loop for example to generate the option elements.

Thanks, it is now clear. There is no core functionality you could use to directly achieve this, but I’ll leave some input involving 3rd party packages:

With Tms.Select you can use Nodes as a Data Source. So you could create Nodes containing the data that should later populate the select box. We usually use Psmb.FlatNav to provide an overview of such nodes.

I also think that the experimental Sitegeist.InspectorGadget might provide such functionality, however it is not documented yet and I’ve never used it. Maybe @mficzel could comment on my assumptions or you could give it a try.

1 Like

Hey,

very late to the party :smiley: :smiley: But I just re-discovered my own package GitHub - sandstorm/LazyDataSource: This package implements additional Inspector Editors, behaving like the standard SelectBoxEditor with data sources, but **delegates filtering and searching to the server-side**. which can be used to build this.

All the best,
Sebastian

<?php

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\Neos\Service\DataSource\AbstractDataSource;
use Sandstorm\LazyDataSource\LazyDataSourceTrait;

class FooDataSource extends AbstractDataSource
{

    use LazyDataSourceTrait;

    static protected $identifier = 'drawio-diagram-identifier';

    protected function getDataForIdentifiers(array $identifiers, NodeInterface $node = null, array $arguments = [])
    {
        // all identifiers will be returned as is
        $options = [];
        foreach ($identifiers as $id) {
            $options[$id] = ['label' => $id];
        }
        return $options;
    }

    protected function searchData(string $searchTerm, NodeInterface $node = null, array $arguments = [])
    {
        // the searched term will be allowed as new element
        $options = [];
        $options[$searchTerm] = ['label' => $searchTerm, 'icon' => 'plus'];
        return $options;
    }
}

Thanks @sebastian for sharing this approach!