Refactor template preview data handling in Footer, Header, and Section templates: Updated the viewData method in FooterTemplateForm, HeaderTemplateForm, and SectionTemplateForm schemas to use a closure for dynamic record ID retrieval. Enhanced the template-preview Blade component to accept the record ID, improving data handling and ensuring accurate template previews based on the current record context.

This commit is contained in:
Ümit Tunç
2025-11-03 03:15:31 -03:00
parent 49bff7f2a7
commit 9629652d0a
4 changed files with 59 additions and 17 deletions
@@ -43,10 +43,13 @@ class FooterTemplateForm
// Preview Component - placed after editor
View::make('components.template-preview')
->viewData([
'type' => 'footer',
'fieldName' => 'html_content',
])
->viewData(function ($record) {
return [
'type' => 'footer',
'fieldName' => 'html_content',
'recordId' => $record?->id,
];
})
->columnSpanFull(),
Toggle::make('is_active')
@@ -42,10 +42,13 @@ class HeaderTemplateForm
// Preview Component - placed after editor
View::make('components.template-preview')
->viewData([
'type' => 'header',
'fieldName' => 'html_content',
])
->viewData(function ($record) {
return [
'type' => 'header',
'fieldName' => 'html_content',
'recordId' => $record?->id,
];
})
->columnSpanFull(),
Toggle::make('is_active')
@@ -42,10 +42,13 @@ class SectionTemplateForm
// Preview Component - placed after editor
View::make('components.template-preview')
->viewData([
'type' => 'section',
'fieldName' => 'html_content',
])
->viewData(function ($record) {
return [
'type' => 'section',
'fieldName' => 'html_content',
'recordId' => $record?->id,
];
})
->columnSpanFull(),
Toggle::make('is_active')