Skip to content

Commit

Permalink
Merge pull request #455 from code4romania/379-super-admin-nomenclatoa…
Browse files Browse the repository at this point in the history
…re-beneficii-sociale-error-500-at-save-benefit-without-adding-a-type

fix save benefit without types
  • Loading branch information
gheorghelupu17 authored Dec 27, 2024
2 parents 2a9f454 + 90c6d45 commit aebc3d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,15 @@ protected function getHeaderActions(): array
->url(BenefitResource::getUrl()),
];
}

public function mutateFormDataBeforeCreate(array $data): array
{
foreach ($this->data['benefitTypes'] as $key => $value) {
if (! $value['name']) {
unset($this->data['benefitTypes'][$key]);
}
}

return $data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,13 @@ protected function getHeaderActions(): array
->tooltip(fn (Actions\DeleteAction $action) => $action->isDisabled() ? __('nomenclature.helper_texts.delete_benefit') : ''),
];
}

public function beforeSave(): void
{
foreach ($this->data['benefitTypes'] as $key => $value) {
if (! $value['name']) {
unset($this->data['benefitTypes'][$key]);
}
}
}
}

0 comments on commit aebc3d4

Please sign in to comment.