Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

LessThanJake's avatar

Cannot Edit Extended/Combined Model Data in Pages Form

I'm developing an app that has several types of users: Admins, Clients and Members (3 separate panels). All users have a base record in App\Models\Users and log-in using the same form, but then have extended model and are redirected to the correct Panel based on the "role" added to the users table ("admin","client","member"). I am using a "safeid" field in all the tables as a foreign_id linking the base users table (because the incremental id in users will not match the incremental ids of the other tables).

This is working, in the Resources (List) page it is displaying the combined model data in the columns. The problem/issue is the edit form will only show editable data from the extended model (not the base user fields).

I'm wondering if maybe extending Model\User is not the best way to achieve my goal. Just getting back to Laravel (created a basic app two years ago). There are so many posts and videos regarding what I am trying to do, but I cannot find a definitive answer/example of what I am trying to achieve in Filament using extended models. Here's some code:

App\Model|User

App\Models\Admin

Filament\Resources\AdminResource

Filament\Resources\AdminResource\Pages\EditAdmin

<?php

namespace App\Filament\Resources\AdminResource\Pages;

use App\Filament\Resources\AdminResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditAdmin extends EditRecord
{
    protected static string $resource = AdminResource::class;

    protected function getHeaderActions(): array
    {
        return [
            Actions\DeleteAction::make(),
        ];
    }

    protected function mutateFormDataBeforeFill(array $data): array
    {
        return $data;
    }
}
0 likes
2 replies
LessThanJake's avatar
LessThanJake
OP
Best Answer
Level 1

Figured it out, but it took awhile. You have to call the model (->relationship('user')) in the form fields Grid/Fieldset/etc creation, ie.,

class AdminResource extends Resource
{
    protected static ?string $model = Admin::class;
    protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Grid::make()
                    ->relationship('user')
                    ->schema([
                        TextInput::make('name'),
                        TextInput::make('email')
                    ]),
                TextInput::make('cellphone')
                    ->required()
                    ->label('Cell Phone'),
                TextInput::make('otherphone')
                    ->required()
                    ->label('Other Phone'),

            ]);
    }```
1 like

Please or to participate in this conversation.