I am trying to loop through an array with a foreach statement. I get the array from an API, not mine. I use the foreach from Laravel in the blade. Somehow in my blade if I go thru the array, each one has a type, it only sees the "radio" type. No checkbox or textarea. Wonder why and what I can do to fix it.
<form action="/sendForm" method="post">@csrf
@foreach($survey['data']['formCategories'] as $category)
<h3 id=""></h3> <!-- Enquete -->
<hr/>
@foreach($category['formQuestions'] as $question)
@if($question['type'] === 'header' || $question['type'] === 'text' || $question['type'] === 'date')
<!-- Don't show -->
@else
<div>
<p class="questions"></p>
<fieldset id="" class="form-group">
@foreach($question['formOptions'] as $answer)
@if($question['type'] === "textarea" || $question['type'] === "paragraph")
TextArea
@elseif($question['type'] === "checkbox")
Checkbox
@elseif($question['type'] === "radio")
Radio
@endif
@endforeach
</fieldset>
</div>
@endif
@endforeach
@endforeach
<input type="submit" value="Sent" class="submit-btn" id="versturen">
</form>
In the end I want to show according to type a form input. So if the type is textarea show a textarea, if it's checkbox make a checkbox, and the same with radio.
I am sorry for any bad grammar, and I know it's not the best question, but I didn't know how else to ask.
Aucun commentaire:
Enregistrer un commentaire