@php $count = count($fields); @endphp @foreach($fields as $field) @php // Extract field name (answers[field_name]) preg_match('/name="([^"]+)"/', $field, $matches); $fieldNameRaw = $matches[1] ?? null; $column = null; if ($fieldNameRaw && preg_match('/answers\[(.+?)\]/', $fieldNameRaw, $m)) { $column = $m[1]; } // Get tooltip text if passed from Screen $tooltipText = $tooltips[$column] ?? null; @endphp @if(Str::contains($field, 'answers[comments]'))
{!! $field !!}
@else
{{-- Inject tooltip icon AFTER label --}} {!! $field !!} @if(!empty($showApplyToAll) && $fieldNameRaw)
@endif
@endif @endforeach {{-- Fillers to complete 3-column rows --}} @if($count < 3 && collect($fields)->filter(fn($f) => Str::contains($f, 'answers[comments]'))->isEmpty()) @for($i = $count; $i < 3; $i++)
@endfor @endif