Group custom Data types

Hello everyone,
i’m new to Omeka S and this might be a silly question.
I have to create specific data types and i am following the guidelines from:

So far, just to test, i created two Data types classes and everything works just fine.
I would just want to see them grouped together in the frontend - under a custom label, like the Value Suggests or Resource that you can see in the attached image. How can i do that? is there some docs for it?
Thanks in advance

DataTypeInterface includes the getOptgroupLabel() method. Simply add this method to your data type classes and return the label of the optgroup, like so:

public function getOptgroupLabel()
    return 'My optgroup label'; // @translate
1 Like

Thank you!
That is perfect!

I take this opportunity to address another doubt related to my data types group.
Let’s say that i created a series of classes:

 return [
            'data_types' => [
                'invokables' => [
                    'mydatatype:date' => DataType\Date::class,
                    'mydatatype:note' => DataType\Note::class,
                    'mydatatype:occasion' => DataType\Occasion::class,
                    'mydatatype:measure' => DataType\Measure::class,
                    'mydatatype:destination' => DataType\Destination::class,
                    'mydatatype:surname' => DataType\Surname::class,

and i linked some of them in a resource template. Nonetheless i am able to display just the first two from my data_types array in the frontend. The rest are not rendered and i only see the “Add Value” button.

What am i missing?

It may be that some of your data types have empty strings as labels. Make sure your data types have unique strings returned from DataTypeInterface::getLabel().

Thanks for answering me again.
Yes all data types have a public function getLabel() which returns a unique string. What is weird is the fact they get “rendered” according to the order in my invokables array. Jut the first two elements get the label and work properly, the other don’t.

'invokables' => [
'mydatatype:date' => DataType\Date::class, <- this gets rendered
'mydatatype:occasion' => DataType\Occasion::class, <- this gets rendered
'mydatatype:note' => DataType\Note::class, <- this becomes Add Value
'mydatatype:measure' => DataType\Measure::class, , <- this becomes Add Value

If i flip them:

'invokables' => [
'mydatatype:note' =>DataType\Note::class, <- this gets rendered
'mydatatype:measure' => DataType\Measure::class, ,<- this gets rendered
'mydatatype:date' => DataType\Date::class,  <- this becomes Add Value
'mydatatype:occasion' => DataType\Occasion::class, <- this becomes Add Value

I just realised that i only have the problem with when i use textareas instead of input fields

I cannot reproduce the error, nor can I deduce how the error is possible without returning an empty string from getLabel(). There must be some condition that I’m not anticipating, such as an interaction with another module. I’d continue working on it. It may be helpful to refer to custom data types from other modules, such as NumericDataTypes, ValueSuggest, and CustomVocab.