I want to have the registration form below that:
- if "
allParticipants == 1
" it should appear the message: "<p>Please fill all form fields. Your tickets will be send to <b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b>.</p>
" (this is working) - else, if "
allParticipants == 0
" and there are no custom questions, that is "$selectedRtype['questions']
" isempty
it should appear the message "<p>Is not necessary additional info. Your tickets will be send to "<b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b></p>
" (this is working) - if "
allParticipants == 0
" and there are custom questions, that is, "$selectedRtype['questions']
" is notempty
, it shoud appear the message "<p>Your tickets will be send to <b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b>.You only need to answer to the custom questions below.</p>
" (this is not working)
But its not working for the third scenario, for when "if "allParticipants == 0
" and there are custom questions," the message that appears is "<p>Is not necessary additional info. Your tickets will be send to "<b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b></p>
", but the message that should appear in this case is "<p>Your tickets will be send to <b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b>.You only need to answer to the custom questions below. </p>
".
Do you know where is the issue?
// form part where are the conditions:
<form method="post" id="step1formfree" action="">
{{csrf_field()}}
@if (!is_null($allParticipants) && is_int($allParticipants))
@if($allParticipants == 1)
<p>Please fill all form fields. Your tickets will be send to <b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b>.</p>
@else
// if there are no custom questions the message should be only "Is not necessary additional info. Your tickets will be sent to"
@if(is_null($selectedRtype['questions']))
<p>Is not necessary additional info. Your tickets will be sent to
<b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b></p>
// if the user selected in the previous page tickets that have associated custom questions the message should be "Your tickets will be send to....You only need to answer to the custom questions below."
@else
<p>Your tickets will be send to <b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b>.
You only need to answer the custom questions below.
</p>
@endif
@endif
@endif
The {{dd($selectedRtype['questions'])}}
shows:
Collection {#236 ▼
#items: []
}
// complete form
<form method="post" id="step1formfree" action="">
{{csrf_field()}}
@if (!is_null($allParticipants) && is_int($allParticipants))
@if($allParticipants == 1)
<p>Please fill all fields. Your tickets will be send to <b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b>.</p>
@elseif(!is_null($selectedRtype['questions']))
<p>Your tickets will be send to <b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b>.You only need to answer to the custom questions below.</p>
@else
<p>Is not necessary additional info. Your tickets will be send to "<b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b></p>
@endif
<span id="userData" data-name="{{ auth()->user()->name }}" data-surname="{{ auth()->user()->surname }}"></span>
@foreach($selectedRtypes as $k => $selectedRtype)
//{{dd($selectedRtype)}}
@foreach(range(1,$selectedRtype['quantity']) as $val)
@if($allParticipants == 1)
<h6>Participant - {{$val}} - {{$k}}</h6>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="fill_auth_info{{ $val }}" data-id="{{ $k }}_{{ $val }}"name="fill_with_auth_info">
<label class="form-check-label d-flex align-items-center" for="fill_auth_info{{ $val }}">
<span class="mr-auto">Fill with auth user info.</span>
</label>
</div>
<div class="form-group font-size-sm">
<label for="name{{ $k }}_{{ $val }}" class="text-gray">Name</label>
<input type="text" id="name{{ $k }}_{{ $val }}" name="participant_name[]" required class="form-control" value="">
</div>
<div class="form-group font-size-sm">
<label for="surname{{ $k }}_{{ $val }}" class="text-gray">Surname</label>
<input type="text" id="surname{{ $k }}_{{ $val }}" required class="form-control" name="participant_surname[]" value="">
</div>
@foreach($selectedRtype['questions'] as $customQuestion)
<div class="form-group">
<label for="participant_question">{{$customQuestion->question}}</label>
<input type="text"
@if($customQuestion->pivot->required == "1") required @endif
class="form-control" name="participant_question[]">
<input type="hidden" name="participant_question_required[]"
value="{{ $customQuestion->pivot->required }}">
<input type="hidden" value="{{ $customQuestion->id }}" name="participant_question_id[]"/>
</div>
@endforeach
@else
<input type="hidden" value="foo" name="participant_name[]"/>
<input type="hidden" value="bar" name="participant_surname[]"/>
@endif
<input type="hidden" name="rtypes[]" value="{{ $selectedRtype['id'] }}"/>
@endforeach
<div class="form-group">
@if ($allParticipants == 0)
@foreach($selectedRtype['questions'] as $customQuestion)
<label for="participant_question">{{$customQuestion->question}}</label>
<input type="text"
@if($customQuestion->pivot->required == "1") required @endif
class="form-control" name="participant_question[]">
<input type="hidden" name="participant_question_required[]"
value="{{ $customQuestion->pivot->required }}">
<input type="hidden" value="{{ $customQuestion->id }}" name="participant_question_id[]"/>
</div>
@endforeach
@endif
@endforeach
@endif
<input type="submit" href="#step2"
id="goToStep2Free" class="btn btn-primary btn float-right next-step" value="Go to step 2"/>
</form>