fixed filament resource forms

This commit is contained in:
2025-09-10 19:28:16 +02:00
parent 837155f54c
commit 40aa5fc188
10 changed files with 317 additions and 12 deletions

View File

@@ -4,10 +4,20 @@ namespace App\Filament\Resources;
use App\Filament\Resources\EventResource\Pages;
use App\Models\Event;
use App\Models\Tenant;
use App\Models\EventType;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Actions;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\KeyValue;
use UnitEnum;
use BackedEnum;
@@ -18,6 +28,44 @@ class EventResource extends Resource
protected static UnitEnum|string|null $navigationGroup = 'Platform';
protected static ?int $navigationSort = 20;
public static function form(Schema $form): Schema
{
return $form->schema([
Select::make('tenant_id')
->label('Tenant')
->options(Tenant::all()->pluck('name', 'id'))
->searchable()
->required(),
TextInput::make('name')
->label('Event Name')
->required()
->maxLength(255),
TextInput::make('slug')
->label('Slug')
->required()
->unique(ignoreRecord: true)
->maxLength(255),
DatePicker::make('date')
->label('Event Date')
->required(),
Select::make('event_type_id')
->label('Event Type')
->options(EventType::all()->pluck('name', 'id'))
->searchable(),
TextInput::make('default_locale')
->label('Default Locale')
->default('de')
->maxLength(5),
Toggle::make('is_active')
->label('Is Active')
->default(true),
KeyValue::make('settings')
->label('Settings')
->keyLabel('Key')
->valueLabel('Value'),
])->columns(2);
}
public static function table(Table $table): Table
{
return $table