- Issue created by @nicklasmf
Instead of returning the field name (often field_*) in the response as key, you might want to set a prettier name or somehow customize the key.
Instead of the following:
"transform_mode": "default",
"field_last_activity": "tir, 09/04/2024 - 14:06",
"uid": {
"type": "entity",
"entity_type": "user",
[..]
Customization would allow the following:
"transform_mode": "default",
"last_activity": "tir, 09/04/2024 - 14:06",
"creator": {
"type": "entity",
"entity_type": "user",
[..]
We could add a textfield in the settings for allowing customization. See image for visual.
Something like:
public function settingsForm(array $form, FormStateInterface $form_state) {
return [
'key' => [
'#type' => 'textfield',
'#title' => $this->t('Key for field in response'),
'#default_value' => $this->getSetting('key'),
'#required' => FALSE,
],
];
}
And then figure out how to use it in Transformer.php.
Active
1.0
Code