diff --git a/app/Http/Controllers/ResponseController.php b/app/Http/Controllers/ResponseController.php index 60b1a59..6f6ee4b 100644 --- a/app/Http/Controllers/ResponseController.php +++ b/app/Http/Controllers/ResponseController.php @@ -118,13 +118,13 @@ class ResponseController extends Controller $validatedData = $request->validate([ - 'answers' => 'required|array', - 'answers.*' => 'required', + 'answers' => 'array', + 'answers.*' => '', ]); foreach ($requiredQuestionIds as $requiredQuestionId) { - if (!array_key_exists($requiredQuestionId, $validatedData['answers'])) { + if (!isset($validatedData['answers'][$requiredQuestionId]) || empty($validatedData['answers'][$requiredQuestionId])) { return redirect()->back() ->withErrors(['errors' => 'Please answer all required questions.']) ->withInput(); diff --git a/resources/views/forms/create.blade.php b/resources/views/forms/create.blade.php index 9d82daa..0f557f3 100644 --- a/resources/views/forms/create.blade.php +++ b/resources/views/forms/create.blade.php @@ -62,7 +62,7 @@ - +
diff --git a/resources/views/forms/edit.blade.php b/resources/views/forms/edit.blade.php index 56a540c..a31c7e2 100644 --- a/resources/views/forms/edit.blade.php +++ b/resources/views/forms/edit.blade.php @@ -21,7 +21,7 @@ -