Hello,
I have a datasource to link users to a node. I got it working, but it’s not perfect yet, because the property is saved as the node identifier and it doesn’t convert to the User model automatically. Here’s my configuration:
yaml
author:
#type: Neos\Neos\Domain\Model\User
type: string
ui:
label: Author
reloadPageIfChanged: true
inspector:
group: document
editor: 'Neos.Neos/Inspector/Editors/SelectBoxEditor'
editorOptions:
placeholder: Choose author
dataSourceIdentifier: my-datasource-identifier
UserDataSouce.php
/**
* Get data
*
* The return value must be JSON serializable data structure.
*
* @param NodeInterface $node The node that is currently edited (optional)
* @param array $arguments Additional arguments (key / value)
* @return mixed JSON serializable data
* @api
*/
public function getData(NodeInterface $node = null, array $arguments)
{
$options = [];
foreach ($this->userRepository->findAll() as $user) {
/** @var $user User */
$options[] = [
'label' => $user->getLabel(),
'value' => $this->persistenceManager->getIdentifierByObject($user),
];
}
return $options;
}
Then in fusion, author
will be a string, but I need it to be an instance of Neos\Neos\Domain\Model\User
:
author = ${q(node).property('author')}
if I switch the author type to Neos\Neos\Domain\Model\User
, the inspector doesn’t save the data in the backend.