Files
nutzwerte_fi4/app/Filament/Resources/Inhaltsverzeichnis/Schemas/InhaltsverzeichnisForm.php
T
2025-10-21 07:24:54 +02:00

82 lines
3.4 KiB
PHP

<?php
namespace App\Filament\Resources\Inhaltsverzeichnis\Schemas;
use App\Models\Tabellen;
use App\Models\Textblock;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
class InhaltsverzeichnisForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Section::make('Überschrift')
->schema([
Checkbox::make('neue_seite')
->label('Start neuer Seite')
->columnSpan(2),
Textarea::make('name')
->required()
->label('Kapitel / Absatz')
->columnSpan(2),
Checkbox::make('ueberschrift_anzeigen')
->label('Überschrift angezeigen')
->columnSpan(2),
TextInput::make('ordnungszahl')
->label('Kapitel Index')
->placeholder('3.21')
->numeric()
->default(0)
->belowContent([
'Bei "0" wird der Index im PDF nicht angezeigt',
])
->columnSpan(1),
TextInput::make('seite')
->label('Seitenzahl')
->numeric()
->default(0)
->belowContent([
'Bei "0" wird die Seitenzahl automatisch generiert',
])
->columnSpan(1),
])->columnSpanFull(),
Section::make('Tabellen & Textblöcke')
->hiddenLabel()
->schema([
Select::make('tabellen_id')->label('Tabelle')
->prefixIcon('phosphor-table')
->prefixIconColor(
fn ($record): string => $record->tabellen_id == 0 ? 'gray' : 'primary'
)
->default(0)
->options(function () {
$res = Tabellen::all()->pluck('name', 'id')->toArray();
array_unshift($res, 'Ohne Tabelle');
return $res;
}),
Select::make('textblock_id')->label('Textblock')
->prefixIcon('phosphor-article')
->prefixIconColor(
fn ($record): string => $record->textblock_id == 0 ? 'gray' : 'primary'
)
->default(0)
->options(function () {
$res = Textblock::all()->pluck('name', 'id')->toArray();
array_unshift($res, 'Ohne Textblock');
return $res;
}),
])->columnSpanFull(),
]);
}
}