Add data transformation for default_data fields in template forms: Implemented mutateFormDataBeforeSave method in Create and Edit pages for Footer, Header, and Section templates to properly format nested default_data fields into an array structure before saving. This enhancement improves data handling and ensures consistency across template forms.

This commit is contained in:
Ümit Tunç
2025-11-03 16:16:06 -03:00
parent ef1e8e8d5c
commit 5b14260622
8 changed files with 196 additions and 1 deletions
+7 -1
View File
@@ -267,7 +267,7 @@ class TemplateService
/**
* Replace placeholders in HTML with actual data
* Supports both {text.title} and {{text.title}} formats
* Also supports {menu} placeholder for menu rendering
* Also supports {menu} and {staticMenu} placeholders for menu rendering
*/
public static function replacePlaceholders(string $html, array $data): string
{
@@ -276,6 +276,12 @@ class TemplateService
$renderedMenu = \App\Services\MenuService::render();
$html = str_replace('{menu}', $renderedMenu, $html);
}
// Handle special {staticMenu} placeholder
if (str_contains($html, '{staticMenu}')) {
$renderedStaticMenu = view('components.static-menu')->render();
$html = str_replace('{staticMenu}', $renderedStaticMenu, $html);
}
// First, parse all placeholders in the format {type.field_name}
preg_match_all('/\{([a-z]+\.[a-z_]+)\}/i', $html, $matches);