@extends('layouts.frontendapp') @php use Illuminate\Support\Str; @endphp @section('content')

{{ $form->title }}

@if(!empty($form->description))

{{ $form->description }}

@endif
@if(session('success'))
{{ session('success') }}
@endif @if($errors->any())
    @foreach($errors->all() as $err)
  • {{ $err }}
  • @endforeach
@endif
@csrf @foreach($form->form_data as $index => $field) {{-- @foreach($form->form_data as $index => $field) --}} @php $type = $field['type'] ?? 'text'; $label = $field['label'] ?? ucfirst($type); $name = Str::slug($label, '_'); $idBase = "f{$index}_" . preg_replace('/[^a-zA-Z0-9_-]/', '_', $name); $isRequired = in_array('required', $field['validation'] ?? []); $min = $field['min'] ?? null; $max = $field['max'] ?? null; $logic = $field['conditional_logic'] ?? null; $hasLenRule = in_array($type, ['text','email','textarea','number']) && ($min || $max); // Fixed: More appropriate autocomplete values $autocomplete = match($type) { 'text' => 'name', 'email' => 'email', 'number' => 'off', 'date' => 'bday', 'password' => 'new-password', 'textarea' => 'off', 'select' => 'off', 'radio' => 'off', 'checkbox' => 'off', default => 'off', }; @endphp
@switch($type) @case('text') @case('email') @case('number') @case('date') @case('password') @break @case('textarea') @break @case('select') @break @case('radio') {{-- Fixed: Proper fieldset structure with legend --}}
{{ $label }} @if($isRequired) @endif @foreach($field['options'] ?? [] as $i => $opt) @php $rid = "{$idBase}_r{$i}"; @endphp
@endforeach
@break @case('checkbox') {{-- Fixed: Proper fieldset structure with legend --}}
{{ $label }} @if($isRequired) @endif @foreach($field['options'] ?? [] as $i => $opt) @php $cid = "{$idBase}_c{$i}"; @endphp
@endforeach
@break @endswitch
@if($isRequired) This field is required. @endif @if($hasLenRule) @if($type === 'number') @if(!is_null($min) && !is_null($max)) Range: {{ $min }}–{{ $max }}. @elseif(!is_null($min)) Minimum: {{ $min }}. @elseif(!is_null($max)) Maximum: {{ $max }}. @endif @else @if($min && $max) {{ $min }}–{{ $max }} characters. @elseif($min) Minimum {{ $min }} characters. @elseif($max) Maximum {{ $max }} characters. @endif @endif @endif
Please provide a valid {{ strtolower($label) }}.
@endforeach
{{-- --}}
@endsection {{-- Additional CSS for better fieldset styling --}}