diff --git a/app/Http/Requests/UpdateReportRequest.php b/app/Http/Requests/UpdateReportRequest.php index b93e7df..4f51db8 100644 --- a/app/Http/Requests/UpdateReportRequest.php +++ b/app/Http/Requests/UpdateReportRequest.php @@ -7,6 +7,7 @@ use App\Models\FormField; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Route; use Illuminate\Validation\Rule; use Illuminate\Validation\Rules\File; @@ -121,6 +122,12 @@ public function rules(): array }, json_decode($field->listvalues)); if (! $field->required) { $accepted_values[] = '-1'; + } else { + if (Request::input("f{$field->id}") === '-1') { + throw ValidationException::withMessages([ + "f{$field->id}" => ['Πρέπει να επιλέξετε κάτι από τη λίστα'], + ]); + } } $field_rules[] = Rule::in($accepted_values); } elseif ($field->type === FormField::TYPE_TELEPHONE) { diff --git a/resources/views/report/show.blade.php b/resources/views/report/show.blade.php index eaee01c..a18e69f 100644 --- a/resources/views/report/show.blade.php +++ b/resources/views/report/show.blade.php @@ -35,7 +35,8 @@