You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a Builder is used in a Resource managed by filament/spatie-laravel-translatable-plugin, the error Undefined array key "afterItem" is returned when trying to insert a block between others.
I was able to trace the error to this line and it arises because the blocks for translations do not have a UUID:
@AlexisSerneels Hi! There are two reasons why this happens: When you switch the locale to French in your example, the spatie-laravel-translatable-plugin resets the data array keys from uuid's to integers (plugin code). Then, in our block-picker.blade.php, we have an if statement where we check that the $afterItem variable is set, but because it has a zero value, it fails. See the video below, please:
Screencast.2024-04-16.15.53.15.mp4
As a quick solution you can create a new class that extends Filament\Forms\Components\Builder\Block and create custom view for it with "isset" fix.
Package
filament/filament
Package Version
v3.2.35
Laravel Version
v10.45.1
Livewire Version
No response
PHP Version
PHP 8.3.3
Problem description
When a Builder is used in a Resource managed by
filament/spatie-laravel-translatable-plugin
, the errorUndefined array key "afterItem"
is returned when trying to insert a block between others.I was able to trace the error to this line and it arises because the blocks for translations do not have a UUID:
filament/packages/forms/src/Components/Builder.php
Line 190 in 27dca4d
Here is the dump for the
$arguments
when saving in English:Here is the dump for the
$arguments
when saving in other languages.We can see the UUID and
afterItem
key is missing.Here is the full error in video:
CleanShot.2024-02-23.at.09.48.40.mp4
Expected behavior
No error should occur.
Steps to reproduce
Reproduction repository
https://github.com/AlexisSerneels/filament-issue
Relevant log output
No response
The text was updated successfully, but these errors were encountered: