Skip to main content
Version: 2024.2

Select Types With Dynamic Options

For the select & multiselect datatype you can specify a dynamic options provider class. This allows you to generate a list of valid options on-the-fly instead of using a static list. The select datatype also allows you to define the default option at runtime.

You can also add some additional static data which will be passed to the data provider.

Note that there are two ways to define an options provider.

Either simply specify the class name ...

Select FieldSelect FieldSelect Field

... or the name of a Symfony service (notice the prefix). Select FieldSelect FieldSelect Field

The services.yaml would then look like this:

class: Website\OptionsProvider
public: true

You have to implement the Pimcore\Model\DataObject\ClassDefinition\DynamicOptionsProvider\SelectOptionsProviderInterface

Implement the following methods:

  • getOptions should return a list of valid options in the format indicated below
  • getDefaultValue returning the default value
  • hasStaticOptions should return whether your options are depending on the object context (i.e. different options for different objects) or not. This is especially important for the object grid. For object-context depending option there will be no batch assignment mode. Also, filtering can only be done through a text field instead of the options list.

namespace Website;

use Pimcore\Model\DataObject\ClassDefinition\Data;
use Pimcore\Model\DataObject\ClassDefinition\DynamicOptionsProvider\SelectOptionsProviderInterface;

class OptionsProvider implements SelectOptionsProviderInterface
public function getOptions(array $context, Data $fieldDefinition): array
$object = isset($context["object"]) ? $context["object"] : null;
$fieldname = "id: " . ($object ? $object->getId() : "unknown") . " - " .$context["fieldname"];
$result = array(

array("key" => $fieldname .' == A', "value" => 2),
array("key" => $fieldname .' == C', "value" => 4),
array("key" => $fieldname .' == F', "value" => 5)

return $result;

* Returns the value which is defined in the 'Default value' field
public function getDefaultValue(array $context, Data $fieldDefinition): ?string
return $fieldDefinition->getDefaultValue();

public function hasStaticOptions(array $context, Data $fieldDefinition): bool
return true;


This will generate the following options.

Select FieldSelect FieldSelect Field

Context Information for the Provider Class

Note that depending the use case not all of the infos will be available. Especially the existence of the object paramater cannot be guaranteed because the provider class will also be called when a class is saved or if you programmatically call $class->getFieldDefinitions(). Layout definition calls can be distinguished from other ones by checking if the purpose parameter is set to layout

The purpose parameter can take the following values:

layoutedit mode layout
gridconfiggrid configuration - usually no need to specify dynamic options
gridviewgrid view

Object (top-level)

objectthe "object"
fieldnamethe name of the select field (e.g. dynSelect)


ownerNamethe name of the localized field ("localizedfields")
objectthe "object"
fieldnamethe name of the select field (e.g. dynSelect)


containerKeythe type of the object brick
outerFieldnamethe object's object brick attribute
objectthe "object"
fieldNamethe name of the attribute inside the object brick


containerKeythe type of the fieldcollection
subContainerTypesub container type (e.g. localized field inside a field collection)
outerFieldnamethe object's field collection attribute
objectthe "object"
fieldNamethe name of the attribute inside the fieldcollection

Classification Store

ownerNamethe name of the classificationstore attribute
fieldnamethe name of the attribute inside the fieldcollection
groupIdgroup id
keyIdkey id
keyDefinitionthe fielddefinition of the classificationstore attribute