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:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user