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 @@
- Συμπληρωμένη φόρμα - {{ $school?->name }} {{ $teacher?->surname }} {{ $teacher?->name }} {{ $other_teacher?->name }} + Συμπληρωμένη φόρμα - {{ $school?->name }} {{ $teacher?->surname }} + {{ $teacher?->name }} {{ $other_teacher?->name }}
@php @@ -44,7 +45,7 @@ ->data() ->where('school_id', $school->id) ->max('record'); - } else if ($teacher !== null) { + } elseif ($teacher !== null) { $total_records = $form ->data() ->where('teacher_id', $teacher->id) @@ -70,7 +71,8 @@ $options = json_decode($field->options); @endphp - id}") }}"> + id}") ?? [] }}"> @endforeach @if ($form->multiple) {{-- Αν επιτρέπονται πολλαπλές εγγραφές --}}