@php $pageTitle = $settings['overrideTitle'] ? $settings['overrideTitle'] : trans('common.edit_item_', ['item' => $settings['subject_column'] ? parse_attr($form['data']->{$settings['subject_column']}) : trans('common.item')]) . config('default.page_title_delimiter') . $settings['title']; @endphp @extends($settings['guard'].'.layouts.default') @section('page_title', $pageTitle . config('default.page_title_delimiter') . config('default.app_name')) @section('content')
{{-- Page Header (New Universal Component) --}} @if($settings['list']) @endif @if ($settings['view']) @endif @if ($settings['delete']) @endif @php $hasTabs = !empty($form['tabs']); @endphp {{-- Form Content (NO CARD WRAPPER!) --}}
@if ($form['columns']) @if($hasTabs) {{-- Tabs at Page Level (NO card wrapper!) --}} {{-- Tab types: - 'standard': Renders form fields from DataDefinition - 'custom': Renders a Blade view (for non-form content like account deletion, data export) When a custom tab is active, the CRUD's OTP verification and save buttons are hidden. Custom tabs must implement their own verification mechanisms. --}} @php // Group columns by their tab for easier rendering $columnsByTab = collect($form['columns']) ->filter(fn($col) => !$col['hidden'] && isset($col['tab'])) ->groupBy('tab') ->toArray(); // Check if any tabs are custom type (used to conditionally show/hide CRUD elements) $hasCustomTabs = collect($form['tabs'])->contains(fn($tab) => ($tab['type'] ?? 'standard') === 'custom'); // Get the first tab's type to know initial visibility state $firstTabType = collect($form['tabs'])->first()['type'] ?? 'standard'; @endphp @foreach ($form['tabs'] as $tabKey => $tabMeta) @if (($tabMeta['type'] ?? 'standard') === 'custom' && !empty($tabMeta['view'])) {{-- Custom Tab: Render the specified Blade view --}} {{-- Pass common context variables to the custom view --}} @include($tabMeta['view'], [ 'form' => $form, 'settings' => $settings, 'dataDefinition' => $dataDefinition, 'member' => $form['data'], ]) @else {{-- Standard Tab: Render form fields --}}
@foreach ($columnsByTab[$tabKey] ?? [] as $column) @if($column['container_start::edit'] ?? $column['container_start::insert'])
@endif @if($column['classes::edit'] ?? $column['classes::insert'])
@endif @if(!empty($column['conditional']))
{$column['conditional']['field']} ?? '', $column['conditional']['values'])) style="display: none;" @endif> @endif @include('data.form', compact('form', 'column')) @if(!empty($column['conditional']))
@endif @if($column['classes::edit'] ?? $column['classes::insert'])
@endif @if($column['container_end::edit'] ?? $column['container_end::insert'])
@endif @endforeach
@endif
@endforeach
@else {{-- Non-tabbed form: Wrap in clean card --}}
@foreach ($form['columns'] as $column) @if (!$column['hidden']) @if($column['container_start::edit'] ?? $column['container_start::insert'])
@endif @if($column['classes::edit'] ?? $column['classes::insert'])
@endif @if(!empty($column['conditional']))
{$column['conditional']['field']} ?? '', $column['conditional']['values'])) style="display: none;" @endif> @endif @include('data.form', compact('form', 'column')) @if(!empty($column['conditional']))
@endif @if($column['classes::edit'] ?? $column['classes::insert'])
@endif @if($column['container_end::edit'] ?? $column['container_end::insert'])
@endif @endif @endforeach
@endif {{-- Password, OTP Verification, and Save Button sections. These are hidden when a custom tab is active because custom tabs implement their own verification and action buttons. --}} @if ($hasTabs && $hasCustomTabs)
@endif {{-- Password Confirmation --}} @if ($settings['editRequiresPassword'])
@endif {{-- OTP Verification --}} @if ($settings['editRequiresOtp']) @php // Check if there's a valid (non-expired) OTP token in session // This enables a 30-minute grace period for multiple saves $otpSessionKey = "otp_verified_{$settings['guard']}_profile_update"; $existingOtpToken = session($otpSessionKey); $otpTokenExpiry = session("{$otpSessionKey}_expires"); $otpGraceActive = $existingOtpToken && $otpTokenExpiry && now()->lessThan($otpTokenExpiry); @endphp
{{-- Error Message --}}
{{-- Step 1: Send Code --}}

{{ trans('otp.profile_verification_title') }}

{{ trans('otp.profile_send_code_info_generic') }}

{{-- Step 2: Enter Code --}}
{{ trans('otp.code_sent_success_short') }}

{{ trans('otp.step3_didnt_receive') }}

{{-- Step 3: Verified --}}

{{ trans('otp.identity_verified') }}

{{ trans('otp.profile_verified') }}

@endif {{-- Form Actions --}}
@if ($settings['editRequiresOtp']) @else @endif @if($settings['list']) {{ trans('common.cancel') }} @endif
@endif {{-- Close the custom tab conditional wrapper --}} @if ($hasTabs && $hasCustomTabs)
@endif {{-- Custom JavaScript from DataDefinition settings --}} @php $customJs = null; if (!empty($settings['js'])) { if (is_string($settings['js'])) { // String = applies to all views $customJs = $settings['js']; } elseif (is_array($settings['js'])) { // Check for exact match or comma-separated keys containing 'edit' foreach ($settings['js'] as $views => $code) { $viewList = array_map('trim', explode(',', $views)); if (in_array('edit', $viewList) || in_array('all', $viewList)) { $customJs = $code; break; } } } } @endphp @if ($customJs) @endif @if (session('current_tab_index') && $hasTabs) @endif @if ($errors->any()) @endif
@if ($settings['delete']) @endif @stop