|
22 | 22 |
|
23 | 23 | <div class="card bg-light mb-3"> |
24 | 24 | <div class="card-body"> |
25 | | - <form action="{{ route('submit.form') }}" method="post"> |
26 | | - @csrf |
27 | | - <input type="hidden" name="form_id" value="{{ $form_id }}" /> |
28 | | - <input type="hidden" name="field_ids" value="{{ $field_ids }}" /> |
| 25 | + @if(count($fields) > 0) |
| 26 | + <form action="{{ route('submit.form') }}" method="post"> |
| 27 | + @csrf |
| 28 | + <input type="hidden" name="form_id" value="{{ $form_id }}" /> |
| 29 | + <input type="hidden" name="field_ids" value="{{ $field_ids }}" /> |
29 | 30 |
|
30 | | - @foreach($fields as $field) |
31 | | - @php |
32 | | - $options = $field->pivot->options? json_decode($field->pivot->options) : null; |
33 | | - $field_name = 'field_' . $field->pivot->id; |
34 | | - $id_for = 'input-fld-'. $loop->iteration; |
35 | | - @endphp |
| 31 | + @foreach($fields as $field) |
| 32 | + @php |
| 33 | + $options = $field->pivot->options? json_decode($field->pivot->options) : null; |
| 34 | + $field_name = 'field_' . $field->pivot->id; |
| 35 | + $id_for = 'input-fld-'. $loop->iteration; |
| 36 | + @endphp |
36 | 37 |
|
37 | | - <div class="form-group"> |
38 | | - @if($options->label) |
39 | | - <label for="{{ $id_for }}">{{ $options->label }}</label> |
40 | | - @endif |
| 38 | + <div class="form-group"> |
| 39 | + @if($options->label) |
| 40 | + <label for="{{ $id_for }}">{{ $options->label }}</label> |
| 41 | + @endif |
41 | 42 |
|
42 | | - @switch($field->field_type) |
43 | | - @case("select") |
44 | | - <select id="{{ $id_for }}" name={{ $field_name }} class="custom-select @error($field_name) is-invalid @enderror"> |
45 | | - <option value="">Choose...</option> |
46 | | - @foreach(explode(",", $options->values) as $value) |
47 | | - <option value="{{ trim($value) }}" {{ old($field_name) == trim($value)? "selected" : "" }}>{{ trim($value) }}</option> |
48 | | - @endforeach |
49 | | - </select> |
50 | | - @break |
| 43 | + @switch($field->field_type) |
| 44 | + @case("select") |
| 45 | + <select id="{{ $id_for }}" name={{ $field_name }} class="custom-select @error($field_name) is-invalid @enderror"> |
| 46 | + <option value="">Choose...</option> |
| 47 | + @foreach(explode(",", $options->values) as $value) |
| 48 | + <option value="{{ trim($value) }}" {{ old($field_name) == trim($value)? "selected" : "" }}>{{ trim($value) }}</option> |
| 49 | + @endforeach |
| 50 | + </select> |
| 51 | + @break |
51 | 52 |
|
52 | | - @case("textarea") |
53 | | - <textarea class="form-control @error($field_name) is-invalid @enderror" id="{{ $id_for }}" name={{ $field_name }} rows={{ $options->rows }}>{{ old($field_name) }}</textarea> |
54 | | - @break |
| 53 | + @case("textarea") |
| 54 | + <textarea class="form-control @error($field_name) is-invalid @enderror" id="{{ $id_for }}" name={{ $field_name }} rows={{ $options->rows }}>{{ old($field_name) }}</textarea> |
| 55 | + @break |
55 | 56 |
|
56 | | - @default |
57 | | - <input type="{{ $options->type == "date" ? "text" : $options->type }}" class="form-control {{ $options->type == "date"? "datepicker" : "" }} @error($field_name) is-invalid @enderror" name={{ $field_name }} id="{{ $id_for }}" value="{{ old($field_name) }}" /> |
58 | | - @endswitch |
| 57 | + @default |
| 58 | + <input type="{{ $options->type == "date" ? "text" : $options->type }}" class="form-control {{ $options->type == "date"? "datepicker" : "" }} @error($field_name) is-invalid @enderror" name={{ $field_name }} id="{{ $id_for }}" value="{{ old($field_name) }}" /> |
| 59 | + @endswitch |
59 | 60 |
|
60 | | - @error($field_name) |
61 | | - <div class="invalid-feedback"> |
62 | | - {{ $errors->first($field_name) }} |
63 | | - </div> |
64 | | - @enderror |
65 | | - </div> |
66 | | - @endforeach |
| 61 | + @error($field_name) |
| 62 | + <div class="invalid-feedback"> |
| 63 | + {{ $errors->first($field_name) }} |
| 64 | + </div> |
| 65 | + @enderror |
| 66 | + </div> |
| 67 | + @endforeach |
67 | 68 |
|
68 | | - <div class="form-group mt-4"> |
69 | | - <button type="submit" class="btn btn-primary"> |
70 | | - <i class="fa fa-paper-plane-o" aria-hidden="true"></i> Submit |
71 | | - </button> |
72 | | - </div> |
73 | | - </form> |
| 69 | + <div class="form-group mt-4"> |
| 70 | + <button type="submit" class="btn btn-primary"> |
| 71 | + <i class="fa fa-paper-plane-o" aria-hidden="true"></i> Submit |
| 72 | + </button> |
| 73 | + </div> |
| 74 | + </form> |
| 75 | + @endif |
74 | 76 | </div> |
75 | 77 | </div> |
76 | 78 | </div> |
|
0 commit comments