@php // Get the form data $form = null; if (!empty($data['form_id'])) { $form = \App\Models\Form::with('submissions')->find($data['form_id']); } // If no form found, show error or fallback if (!$form) { if (auth()->check()) { echo '
' . __('form.form_not_found_admin') . '
'; } return; } // Prepare form display data $formTitle = !empty($data['form_title']) ? $data['form_title'] : $form->form_title; $formSubTitle = !empty($data['form_subtitle']) ? $data['form_subtitle'] : $form->form_subtitle; $formDescription = !empty($data['form_description']) ? $data['form_description'] : $form->form_description; $form->submit_button_text; $successMessage = !empty($data['success_message']) ? $data['success_message'] : $form->success_message; $showTitle = $data['show_form_title'] ?? true; $showDescription = $data['show_form_description'] ?? true; $cssClasses = $data['css_classes'] ?? 'injected-form'; // Generate unique form ID for this component instance $formId = 'injected-form-' . $form->id . '-' . uniqid(); @endphp
@if($showTitle && $formSubTitle) {{ $formSubTitle }} @endif @if($showDescription && $formTitle)

{!! $formTitle !!}

@endif
{{-- Success Message (Hidden by default) --}}
{{ $form->success_message ?: __('form.thank_you_default') }}
{{-- Error Message Container --}}
{{-- Dynamic Form --}}
@csrf @foreach($form->form_fields as $index => $field) @php $fieldName = $field['name'] ?? 'field_' . $index; $fieldType = $field['type'] ?? 'text'; $fieldLabel = $field['label'] ?? ucfirst($fieldName); $fieldPlaceholder = $field['placeholder'] ?? ''; $fieldRequired = $field['required'] ?? false; $fieldValue = $field['default_value'] ?? ''; $fieldClass = $field['class'] ?? ''; $fieldWidth = $field['width'] ?? 'col-12'; $fieldHelp = $field['help_text'] ?? ''; $fieldValidation = $field['validation'] ?? ''; @endphp @php // Map field types to appropriate column widths $columnClass = 'col-md-12 mb-30px'; if ($fieldType === 'textarea') { $columnClass = 'col-md-12 mb-30px'; } elseif (in_array($fieldType, ['text', 'email', 'tel', 'number', 'select'])) { $columnClass = 'col-md-6 mb-30px'; } @endphp
{{-- Render different field types --}} @switch($fieldType) @case('textarea') @break @case('select') @break @case('radio') @if(!empty($field['options']))
@foreach($field['options'] as $optionIndex => $option)
@endforeach
@endif @break @case('checkbox') @if(!empty($field['options']))
@foreach($field['options'] as $optionIndex => $option)
@endforeach
@else
@endif @break @case('file') @break @default @endswitch {{-- Help Text --}} @if($fieldHelp)
{{ $fieldHelp }}
@endif {{-- Field Error Container --}}
@endforeach
{{-- Honeypot Field (spam protection) --}} @if($form->form_settings['enable_honeypot'] ?? true) @endif {{-- hCaptcha --}}

{{ $formDescription }}

{{-- Submit Button --}}
{{-- hCaptcha Script --}} {{-- JavaScript for Form Submission --}}