@foreach ($layout as $node)
@php
$nodeType = $node['type'] ?? '';
@endphp
@if ($nodeType === 'row')
@foreach ($node['columns'] ?? [] as $column)
@php
$width = (int) ($column['width'] ?? 12);
if ($width < 1 || $width > 12) {
$width = 12;
}
$colClass = $width < 12 ? 'col-12 col-lg-' . $width : 'col-12';
@endphp
@include('admin.forms.partials.form-layout-readonly', [
'layout' => $column['items'] ?? [],
'values' => $values ?? [],
])
@endforeach
@elseif ($nodeType === 'table')
@php
$nodeCellWidth = (int) ($node['cellWidth'] ?? 0);
$nodeCellHeight = (int) ($node['cellHeight'] ?? 0);
@endphp
@elseif ($nodeType === 'section')
{{ $node['title'] ?? '' }}
@include('admin.forms.partials.form-layout-readonly', [
'layout' => $node['items'] ?? [],
'values' => $values ?? [],
])
@elseif ($nodeType === 'content')
{!! $node['html'] ?? '' !!}
@elseif ($nodeType === 'field')
@php
$field = $node['field'] ?? [];
$fieldKey = $field['key'] ?? '';
$fieldLabel = $field['label'] ?? $fieldKey;
$fieldType = $field['type'] ?? 'text';
$fieldOptions = $field['options'] ?? [];
$value = $fieldKey !== '' ? ($values[$fieldKey] ?? null) : null;
$labelPosition = strtolower(trim((string) ($field['labelPosition'] ?? 'left')));
if ($labelPosition === '') {
$labelPosition = 'left';
}
$labelWidth = (int) ($field['labelWidth'] ?? 0);
$labelMargin = (int) ($field['labelMargin'] ?? 0);
$labelAlign = strtolower(trim((string) ($field['labelAlign'] ?? '')));
$inputAlign = strtolower(trim((string) ($field['inputAlign'] ?? '')));
$hideLabel = !empty($field['hideLabel']) || $labelPosition === 'hidden';
$prefix = trim((string) ($field['prefix'] ?? ''));
$suffix = trim((string) ($field['suffix'] ?? ''));
$description = trim((string) ($field['description'] ?? ''));
$tooltip = trim((string) ($field['tooltip'] ?? ''));
$surveyQuestions = $field['questions'] ?? [];
$surveyValues = $field['surveyValues'] ?? [];
$labelAfter = in_array($labelPosition, ['right', 'bottom'], true);
$rowClasses = ['form-layout-row'];
if (in_array($labelPosition, ['top', 'bottom'], true)) {
$rowClasses[] = 'form-layout-row-vertical';
}
if ($labelPosition === 'right') {
$rowClasses[] = 'form-layout-row-right';
}
if ($hideLabel) {
$rowClasses[] = 'form-layout-row-no-label';
}
$rowStyle = '';
if ($labelWidth > 0) {
$rowStyle .= '--label-width:' . $labelWidth . 'px;';
}
if ($labelMargin > 0) {
$rowStyle .= '--label-gap:' . $labelMargin . 'px;';
}
if ($inputAlign !== '') {
$rowStyle .= '--input-align:' . $inputAlign . ';';
}
$inputWidth = (int) ($field['inputWidth'] ?? $field['input_width'] ?? 0);
$inputHeight = (int) ($field['inputHeight'] ?? $field['input_height'] ?? 0);
if ($inputWidth < 0) {
$inputWidth = 0;
}
if ($inputHeight < 0) {
$inputHeight = 0;
}
$controlStyle = '';
if ($inputWidth > 0) {
$controlStyle .= 'width:' . $inputWidth . 'px;max-width:100%;';
}
if ($inputHeight > 0) {
$controlStyle .= 'min-height:' . $inputHeight . 'px;';
}
$displayValue = '-';
$linkPath = null;
$displayHtml = null;
if ($fieldType === 'survey' && is_array($value)) {
$questionLabels = [];
foreach ($surveyQuestions as $question) {
$qKey = (string) ($question['value'] ?? $question['label'] ?? '');
if ($qKey === '') {
continue;
}
$questionLabels[$qKey] = (string) ($question['label'] ?? $qKey);
}
$valueLabels = [];
foreach ($surveyValues as $opt) {
$optValue = (string) ($opt['value'] ?? '');
$valueLabels[$optValue] = (string) ($opt['label'] ?? $optValue);
}
$lines = [];
foreach ($value as $qKey => $answer) {
if ($answer === '' || $answer === null) {
continue;
}
$qLabel = $questionLabels[$qKey] ?? (string) $qKey;
$aLabel = $valueLabels[(string) $answer] ?? (string) $answer;
$lines[] = e($qLabel) . ': ' . e($aLabel);
}
if ($lines) {
$displayHtml = '' . implode('
', $lines) . '
';
$displayValue = '';
}
} elseif ($fieldType === 'address' && is_array($value)) {
$parts = array_filter(array_map('trim', $value));
if ($parts) {
$displayHtml = '' . implode('
', array_map('e', $parts)) . '
';
$displayValue = '';
}
} elseif (is_array($value)) {
if (isset($value['name'])) {
$displayValue = (string) $value['name'];
if (!empty($value['path'])) {
$linkPath = asset($value['path']);
}
} elseif ($value) {
$displayValue = implode(', ', array_map('strval', $value));
}
} elseif (is_bool($value)) {
$displayValue = $value ? 'Evet' : 'Hayir';
} elseif ($value !== null && $value !== '') {
$displayValue = (string) $value;
}
if (in_array($fieldType, ['select', 'radio'], true) && $fieldOptions && $value !== null && $value !== '') {
foreach ($fieldOptions as $option) {
if ((string) ($option['value'] ?? '') === (string) $value) {
$displayValue = (string) ($option['label'] ?? $displayValue);
break;
}
}
}
if ($fieldType === 'selectboxes' && is_array($value)) {
$selected = [];
if (array_is_list($value)) {
$selected = $value;
} else {
foreach ($value as $key => $checked) {
if ($checked) {
$selected[] = $key;
}
}
}
if ($fieldOptions && $selected) {
$labels = [];
foreach ($fieldOptions as $option) {
if (in_array((string) ($option['value'] ?? ''), array_map('strval', $selected), true)) {
$labels[] = (string) ($option['label'] ?? $option['value']);
}
}
if ($labels) {
$displayValue = implode(', ', $labels);
}
} elseif ($selected) {
$displayValue = implode(', ', array_map('strval', $selected));
}
}
if ($fieldType === 'checkbox') {
$displayValue = !empty($value) ? 'Evet' : 'Hayir';
}
if (($prefix !== '' || $suffix !== '') && $displayValue !== '-' && $displayValue !== '') {
$displayValue = $prefix . $displayValue . $suffix;
}
if ($fieldType === 'signature' && is_string($value) && str_starts_with($value, 'data:image')) {
$displayHtml = '
';
}
@endphp
@if ($fieldKey !== '')
@if (!$labelAfter)
@endif
@if ($displayHtml)
{!! $displayHtml !!}
@elseif ($linkPath)
{{ $displayValue }}
@else
{{ $displayValue }}
@endif
@if ($description !== '')
{{ $description }}
@endif
@if ($labelAfter)
@endif
@endif
@endif
@endforeach