FilamentF
Filament10mo ago
BB

Reorder between Builders

Is it possible to allow reordering between two builders?
If block is created in the first one to be able to also be moved in the other builder.

Current code:
Repeater::make('content')
  ->columnSpanFull()
  ->defaultItems(1)
  ->schema([
    Select::make('columns')
    ->options([
      'grid-cols-1' => "One Column 1/1",
      'grid-cols-2-span-2-2' => "Two Columns 2/2",
      'grid-cols-2-span-2-4' => 'Two Columns 2/4',
      'grid-cols-2-span-4-2' => 'Two Columns 4/2',
     ])
      ->default('grid-cols-1')
      ->live()
      ->reactive(),

    Grid::make()
    ->columns(2)
    ->schema(fn (Get $get) => [
      Builder::make('column1')
      ->hiddenLabel()
      ->blocks(require app_path('Filament/Blocks/ContentBlocks.php'))
      ->addActionLabel(__('Add block'))
      ->blockNumbers(false)
      ->collapsible()
      ->columnSpan(fn (Get $get) => ($get('columns') !== 'grid-cols-1') ? 1 : 12)
      ->collapsed(fn(string $context): bool => $context !== 'create')
      ->reorderable()
      ->cloneable(),

      Builder::make('column2')
      ->hiddenLabel()
      ->blocks(require app_path('Filament/Blocks/ContentBlocks.php'))
      ->columns((int)$get('column2_width'))
      ->addActionLabel(__('Add block'))
      ->blockNumbers(false)
      ->collapsible()
      ->collapsed(fn(string $context): bool => $context !== 'create')
      ->cloneable()
      ->reorderable()
      ->visible(fn (Get $get) => $get('columns') !== 'grid-cols-1'),
      ]),
    ]),
Was this page helpful?