56 lines
2.2 KiB
PHP
56 lines
2.2 KiB
PHP
<?php
|
||
|
||
namespace App\Filament\Admin\Resources\SectionTemplates\Schemas;
|
||
|
||
use Filament\Forms\Components\CodeEditor;
|
||
use Filament\Forms\Components\TextInput;
|
||
use Filament\Forms\Components\Toggle;
|
||
use Filament\Schemas\Components\Section;
|
||
use Filament\Schemas\Components\View;
|
||
use Filament\Schemas\Schema;
|
||
use Filament\Forms\Components\CodeEditor\Enums\Language;
|
||
|
||
class SectionTemplateForm
|
||
{
|
||
public static function configure(Schema $schema): Schema
|
||
{
|
||
return $schema
|
||
->components([
|
||
Section::make(__('section-templates.section_general'))
|
||
->schema([
|
||
TextInput::make('title')
|
||
->label(__('section-templates.field_title'))
|
||
->required()
|
||
->maxLength(255)
|
||
->columnSpanFull(),
|
||
|
||
CodeEditor::make('html_content')
|
||
->label(__('section-templates.field_html_content'))
|
||
->required()
|
||
->live(onBlur: false) // Real-time updates
|
||
->language(Language::Html)
|
||
->columnSpanFull()
|
||
->helperText(__('section-templates.field_html_content_help'))
|
||
->extraAttributes([
|
||
'style' => 'min-height: 200px; overflow-x: auto;', // Metni yatay kaydırma eklendi
|
||
'data-field-name' => 'html_content',
|
||
]),
|
||
|
||
// Preview Component - placed after editor
|
||
View::make('components.template-preview')
|
||
->extraAttributes([
|
||
'data-type' => 'section',
|
||
'data-field-name' => 'html_content',
|
||
])
|
||
->columnSpanFull(),
|
||
|
||
Toggle::make('is_active')
|
||
->label(__('section-templates.field_is_active'))
|
||
->default(true)
|
||
->inline(false),
|
||
])
|
||
->columnSpanFull(),
|
||
]);
|
||
}
|
||
}
|