Use two properties as component value

I have a custom component that I want to set the component value to an array (tuple) made up of two columns in the database and when saving, extract the two values from the tuple and save in separate columns in the database. I've tried a number of different things to get this to work. Any suggestions? I'm assuming using hooks I can do this but can't quite find the right combination.
1 Reply
Brian Kidd
Brian KiddOP16mo ago
I've managed to get the component initial value set properly by adding this to the Edit Screen:
protected function mutateFormDataBeforeFill($data): array
{
$data['dates'] = [$data['start'], $data['end']];

return $data;
}
protected function mutateFormDataBeforeFill($data): array
{
$data['dates'] = [$data['start'], $data['end']];

return $data;
}
Want results from more Discord servers?
Add your server