Dec 15, 2024
0
Level 7
Edit 1 to 1 relation in FIlament not working
I have a hasOne relation of the user model to the UserMeta model. The metadata is stored on one row in the database, with column user_id and the rest columns for the other data.
I have created a Filament relation manager and I can render the data in the View User and Edit User pages.
However, when in the user edit page, if I want to edit the meta data and click the edit button, it starts loading but no form modal is shown.
This is my code:
// User model
public function meta(): HasOne
{
return $this->hasOne(UserMeta::class);
}
// UserMeta model
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
// The relationship manager
protected static string $relationship = 'meta';
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('github')
->required()
->maxLength(255),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('user_id')
->columns([
TextColumn::make('github'),
TextColumn::make('linkedin'),
TextColumn::make('facebook'),
TextColumn::make('twitter'),
TextColumn::make('snapchat'),
TextColumn::make('skype'),
])
->actions([
Tables\Actions\EditAction::make(),
]);
}
I think the problem may come from recordTitleAttribute but I am unsure.
Any ideas on how to solve this?
Please or to participate in this conversation.