When using the Collection type, you can create a reference to a record of any collection.
The value of the field will be the primary key of the selected record.
Note that the value will be stored in an array as the target collection may be using a composite primary key. When not using a composite primary key, the array can be assumed to contain a single value.
useForestAdmin\AgentPHP\DatasourceCustomizer\CollectionCustomizer;useForestAdmin\AgentPHP\DatasourceCustomizer\Decorators\Actions\BaseAction;useForestAdmin\AgentPHP\DatasourceCustomizer\Decorators\Actions\Context\ActionContextSingle;useForestAdmin\AgentPHP\DatasourceCustomizer\Decorators\Actions\DynamicField;useForestAdmin\AgentPHP\DatasourceCustomizer\Decorators\Actions\ResultBuilder;useForestAdmin\AgentPHP\DatasourceCustomizer\Decorators\Actions\Types\ActionScope;useForestAdmin\AgentPHP\DatasourceCustomizer\Decorators\Actions\Types\FieldType;$forestAgent->customizeCollection('ticket',function (CollectionCustomizer $builder) { $builder->addAction('Assign ticket',newBaseAction( scope: ActionScope::SINGLE, form: [newDynamicField( label: 'Assignee', description: 'The user to assign the ticket to', type: FieldType::COLLECTION, collectionName: 'user', isRequired: true, ), ] execute: function(ActionContextSingle $context,ResultBuilder $resultBuilder) {// Retrieve user id from the form $formValues = $context->getFormValues(); } )); });