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