Files
roxane/app/Filament/Resources/NotificationTemplates/Schemas/NotificationTemplateForm.php
Nebulae 25885e3b70
All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 1m21s
feat(Password process for new admin, cleaning translations)
2026-04-01 15:50:21 +02:00

49 lines
2.3 KiB
PHP

<?php
namespace App\Filament\Resources\NotificationTemplates\Schemas;
use App\Models\NotificationTemplate;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
class NotificationTemplateForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Section::make(fn (?NotificationTemplate $record) => $record?->name ?? NotificationTemplate::getAttributeLabel('name'))
->afterHeader([
Toggle::make('is_active')
->label(NotificationTemplate::getAttributeLabel('is_active'))
->default(true),
])
->schema([
TextInput::make('name')
->label(NotificationTemplate::getAttributeLabel('name'))
->required(),
TextInput::make('identifier')
->label(NotificationTemplate::getAttributeLabel('identifier'))
->required()
->disabledOn('edit'),
TextInput::make('subject')
->label(NotificationTemplate::getAttributeLabel('subject'))
->required()
->helperText(fn (?NotificationTemplate $record) => $record?->variables
? NotificationTemplate::getAttributeLabel('variables').' : '.implode(', ', array_map(fn ($k) => '{'.$k.'}', array_keys($record->variables)))
: null),
RichEditor::make('body')
->label(NotificationTemplate::getAttributeLabel('body'))
->required()
->helperText(fn (?NotificationTemplate $record) => $record?->variables
? NotificationTemplate::getAttributeLabel('variables').' : '.implode(', ', array_map(fn ($k) => '{'.$k.'}', array_keys($record->variables)))
: null)
->columnSpanFull(),
]),
]);
}
}