FilamentF
Filament15mo ago
Tjiel

Spatie tag name text input field

Hello all, I have created a resource for the spatie tag model:
use Spatie\Tags\Tag;

class TagResource extends Resource
{
    protected static ?string $model = Tag::class;

    protected static ?string $navigationIcon = 'heroicon-o-tag';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Section::make()
                    ->schema([
                        Forms\Components\TextInput::make('name')
                            ->label('Name')
                            ->translateLabel()
                            ->required()
                            ->unique('name', 'tags')
                            ->maxLength(255),

I want the user to be able to change the name of the tag, the problem is that it is saved like the following: {"nl": "test"}. So with the above code I get [object Object], and when I try to submit it, I get the following errror:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'database.name' doesn't exist.
Then I tried to do the form like this.
Forms\Components\TextInput::make('name.nl')
   ->label('Name')
   ->translateLabel()
   ->required()
   ->unique('name', 'tags')
   ->maxLength(255),

This did fill the field with the string I wanted it to fill with, but still the same error ocurs.

Any help would be really appreciated.
Was this page helpful?