Skip to content

Commit

Permalink
Fix partial form submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobeltrame committed Jul 29, 2024
1 parent eb0d3e7 commit 89cc839
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/Http/Controllers/EvaluationGridController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ public function store(EvaluationGridRequest $request, Course $course, Evaluation
EvaluationGridRow::insert(
collect($evaluationGrid->evaluationGridTemplate->evaluationGridRowTemplates)
->map(function ($rowTemplate, $index) use($data, $evaluationGrid) {
return array_merge($data['rows'][$index], ['evaluation_grid_id' => $evaluationGrid->id, 'evaluation_grid_row_template_id' => $rowTemplate->id]);
return array_merge(
// Some defaults
['value' => null, 'notes' => null],
// The user input
$data['rows'][$index],
// Fixed values which may not be changed
['evaluation_grid_id' => $evaluationGrid->id, 'evaluation_grid_row_template_id' => $rowTemplate->id]
);
})
->all()
);
Expand Down

0 comments on commit 89cc839

Please sign in to comment.