How can i save array keys after modify?

If i dump method mutateFormDataBeforeFill i get array what i needed (see first dump screen). But if i dump mutateFormDataBeforeSave original array keys is missing(see second dump screen). I use repeater in form to modify that data:
Repeater::make('properties')
->label('Страницы')
->schema([
/// Inputs here
])
->columns(1)
->itemLabel(fn(array $state): ?string => $state['label'] ?? null)
->columnSpanFull()
->collapsed()
->reorderable(false)
->deletable(false)
->addable(false),
Repeater::make('properties')
->label('Страницы')
->schema([
/// Inputs here
])
->columns(1)
->itemLabel(fn(array $state): ?string => $state['label'] ?? null)
->columnSpanFull()
->collapsed()
->reorderable(false)
->deletable(false)
->addable(false),
How can i save original array keys?
No description
No description
1 Reply
mar5hall
mar5hallOP13mo ago
I use
$keys = array_keys(app(SitemapSettings::class)->properties);

$data['properties'] = collect($data['properties'])->keyBy(function ($item, $key) use ($keys) {
return $keys[$key];
})->toArray();
$keys = array_keys(app(SitemapSettings::class)->properties);

$data['properties'] = collect($data['properties'])->keyBy(function ($item, $key) use ($keys) {
return $keys[$key];
})->toArray();
for map array in beforeSave method. It works as expected and solve my problem. But I think there must be a better solution.
No description
Want results from more Discord servers?
Add your server