@php $indexes = $indexes ?? []; @endphp @foreach($questions as $qIndex => $question) @php $currentIndexes = array_merge($indexes, [$qIndex]); $fieldConfig = is_string($question->field_config) ? json_decode($question->field_config, true) : $question->field_config; $namePath = function($field) use ($section, $currentIndexes) { $path = "sections[" . $section->title . "][questions]"; foreach ($currentIndexes as $i) { $path .= "[" . $i . "][children]"; } $path = preg_replace('/\[children\]$/', '', $path); return $path . "[" . $field . "]"; }; @endphp
Question (Level {{ count($currentIndexes) }})
{{-- hidden ids --}} {{-- Question text --}}
{{-- Type --}}
{{-- Dynamic fields --}}
@php $ans = $question->answer ?? null; @endphp {{-- TOGGLE BUTTONS TYPE --}} @if($question->type == 'toggle-buttons')
Configure Toggle Buttons
{{-- Button 1 Config --}}
@php $btn1Labels = $fieldConfig['btn1_input_labels'] ?? ['cm']; @endphp @foreach($btn1Labels as $idx => $label) @endforeach
{{-- Button 2 Config --}}
@php $btn2Labels = $fieldConfig['btn2_input_labels'] ?? ['feet/inches']; @endphp @foreach($btn2Labels as $idx => $label) @endforeach
{{-- MULTI RADIO TYPE --}} @elseif($question->type == 'multi-radio')
Configure Radio Options
@php $radioOptions = $fieldConfig['radio_options'] ?? ['']; @endphp @foreach($radioOptions as $option)
@endforeach
{{-- DEFAULT (text/text+textarea) --}} @else
btn_status ?? 'yes') == 'yes' ? 'checked' : '' }}>
btn_status ?? '') == 'no' ? 'checked' : '' }}>
@endif
@if($question->type == 'text+textarea')
@endif {{-- children --}}
@if($question->children->count()) @include('admin.includes.question-tree', [ 'questions' => $question->children, 'section' => $section, 'indexes' => $currentIndexes ]) @endif
@endforeach