Files
2025-10-11 17:02:49 +02:00

67 lines
2.8 KiB
PHP

<?php
namespace App\Filament\Resources\Links\Schemas;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Builder\Block;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\Select;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
class LinkForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Section::make()
->schema([
Builder::make('links')
->label('Przyciski')
->addActionLabel('Dodaj przycisk')
->collapsible()
->collapsed()
->reorderable()
->blocks([
Block::make('link')
->label(function (?array $state): string {
if ($state === null) {
return 'Odnośnik';
}
return $state['name'] ?? 'Odnośnik';
})
->schema([
TextInput::make('name')
->label('Nazwa')
->required(),
TextInput::make('icon')
->label('Ikona (FontAwesome)')
->required(),
Select::make('btn_style')
->label('Styl przycisku')
->options([
'primary' => 'Pomarańczowy',
'secondary' => 'Szary',
])
->default('primary')
->required(),
TextInput::make('link')
->label('Link')
->required(),
Toggle::make('external')
->label('Zewnętrzny link')
->required(),
Toggle::make('new_tab')
->label('Otwieraj w nowym oknie')
->required(),
])
->columns(2),
])
])
])->statePath('data');
}
}