Update view component usage in template forms: Replaced extraAttributes with viewData method in HeaderTemplateForm, FooterTemplateForm, and SectionTemplateForm schemas to align with Filament 4.x standards. Enhanced the template-preview Blade component to utilize local variables for type and field name, improving data handling and consistency.
This commit is contained in:
@@ -108,6 +108,7 @@ use Filament\Schemas\Components\Grid; // ✅ Doğru
|
|||||||
use Filament\Schemas\Components\Fieldset; // ✅ Doğru
|
use Filament\Schemas\Components\Fieldset; // ✅ Doğru
|
||||||
use Filament\Schemas\Components\Flex; // ✅ Doğru
|
use Filament\Schemas\Components\Flex; // ✅ Doğru
|
||||||
use Filament\Schemas\Components\Group; // ✅ Doğru - Schema içinde gruplamak için
|
use Filament\Schemas\Components\Group; // ✅ Doğru - Schema içinde gruplamak için
|
||||||
|
use Filament\Schemas\Components\View; // ✅ Doğru - Blade view component
|
||||||
|
|
||||||
// Tabs components (ÖNEMLİ: Schemas namespace!)
|
// Tabs components (ÖNEMLİ: Schemas namespace!)
|
||||||
use Filament\Schemas\Components\Tabs; // ✅ Doğru
|
use Filament\Schemas\Components\Tabs; // ✅ Doğru
|
||||||
@@ -224,6 +225,37 @@ $table
|
|||||||
- `Filament\Forms\Components\Group` diye bir class **YOK**. Schema içinde gruplamak için `Filament\Schemas\Components\Group` kullan!
|
- `Filament\Forms\Components\Group` diye bir class **YOK**. Schema içinde gruplamak için `Filament\Schemas\Components\Group` kullan!
|
||||||
- `Filament\Forms\Get` ve `Filament\Forms\Set` diye class'lar **YOK**. `Filament\Schemas\Components\Utilities\Get` ve `Filament\Schemas\Components\Utilities\Set` kullan!
|
- `Filament\Forms\Get` ve `Filament\Forms\Set` diye class'lar **YOK**. `Filament\Schemas\Components\Utilities\Get` ve `Filament\Schemas\Components\Utilities\Set` kullan!
|
||||||
|
|
||||||
|
#### **Filament 4.x VIEW COMPONENT KULLANIM KURALLARI (KRİTİK!):**
|
||||||
|
|
||||||
|
View component'ine veri iletmek için **sadece `viewData()` metodu** kullanılır:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Filament\Schemas\Components\View;
|
||||||
|
|
||||||
|
// ✅ DOĞRU - viewData() ile veri gönder
|
||||||
|
View::make('components.template-preview')
|
||||||
|
->viewData([
|
||||||
|
'type' => 'header',
|
||||||
|
'fieldName' => 'html_content',
|
||||||
|
])
|
||||||
|
->columnSpanFull();
|
||||||
|
|
||||||
|
// ❌ YANLIŞ - with() metodu ÇALIŞMAZ!
|
||||||
|
View::make('components.template-preview')
|
||||||
|
->with([...]) // ❌ Bu metod View component'inde YOK!
|
||||||
|
|
||||||
|
// ❌ YANLIŞ - extraAttributes() sadece HTML attribute'leri için
|
||||||
|
View::make('components.template-preview')
|
||||||
|
->extraAttributes([
|
||||||
|
'data-type' => 'header', // ❌ Bu view'e değişken olarak GİTMEZ!
|
||||||
|
])
|
||||||
|
```
|
||||||
|
|
||||||
|
**Özet:**
|
||||||
|
- ✅ `->viewData([...])` → Blade view'e değişken gönderir
|
||||||
|
- ❌ `->with([...])` → View component'inde bu metod YOK
|
||||||
|
- ❌ `->extraAttributes([...])` → Sadece HTML attribute'leri için, view değişkenleri için DEĞİL
|
||||||
|
|
||||||
#### **Filament 4.x REPEATER KULLANIM KURALLARI (KRİTİK!):**
|
#### **Filament 4.x REPEATER KULLANIM KURALLARI (KRİTİK!):**
|
||||||
|
|
||||||
Repeater component'ı JSON array formatında tekrarlanan form component'leri oluşturmak için kullanılır.
|
Repeater component'ı JSON array formatında tekrarlanan form component'leri oluşturmak için kullanılır.
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ class FooterTemplateForm
|
|||||||
|
|
||||||
// Preview Component - placed after editor
|
// Preview Component - placed after editor
|
||||||
View::make('components.template-preview')
|
View::make('components.template-preview')
|
||||||
->extraAttributes([
|
->viewData([
|
||||||
'data-type' => 'footer',
|
'type' => 'footer',
|
||||||
'data-field-name' => 'html_content',
|
'fieldName' => 'html_content',
|
||||||
])
|
])
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ class HeaderTemplateForm
|
|||||||
|
|
||||||
// Preview Component - placed after editor
|
// Preview Component - placed after editor
|
||||||
View::make('components.template-preview')
|
View::make('components.template-preview')
|
||||||
->extraAttributes([
|
->viewData([
|
||||||
'data-type' => 'header',
|
'type' => 'header',
|
||||||
'data-field-name' => 'html_content',
|
'fieldName' => 'html_content',
|
||||||
])
|
])
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ class SectionTemplateForm
|
|||||||
|
|
||||||
// Preview Component - placed after editor
|
// Preview Component - placed after editor
|
||||||
View::make('components.template-preview')
|
View::make('components.template-preview')
|
||||||
->extraAttributes([
|
->viewData([
|
||||||
'data-type' => 'section',
|
'type' => 'section',
|
||||||
'data-field-name' => 'html_content',
|
'fieldName' => 'html_content',
|
||||||
])
|
])
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
@php
|
@php
|
||||||
$previewUrl = route('template.preview');
|
$previewUrl = route('template.preview');
|
||||||
$type = $attributes->get('data-type') ?? 'section';
|
$type = $type ?? 'section';
|
||||||
$fieldName = $attributes->get('data-field-name') ?? 'html_content';
|
$fieldName = $fieldName ?? 'html_content';
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
<div
|
<div
|
||||||
x-data="templatePreview(@js($previewUrl), @js($type), @js($fieldName))"
|
x-data="templatePreview(@js($previewUrl), @js($type), @js($fieldName))"
|
||||||
class="template-preview-wrapper w-full"
|
class="template-preview-wrapper w-full"
|
||||||
|
|||||||
Reference in New Issue
Block a user