In relationshipManager, the relationship is not automatically set to ownerRecord
In these screenshot, you can see I'm in the Provider model, in the OpenAI Provider.
When I click the "Create" in the Relationship Manager to create a new Model, the Provider is not automatically set to "Open AI".


11 Replies
I'd like it to prefill "Open AI" as the provider, since I opened the modal from this relationship.
Maybe it could even be disabled

Here is the relationshipManager code:
And the form in the Resource:
Wait ! Am I supposed to omit the relationship field when I'm creating via the relationship manager ?
I'm not sure how I would do that and still reuse my resource form !
yeah you dont need the relationship field
we automatically associate it
If I reuse the form, how do I hide this field only in the relationship manager ?
you can do a hiddenOn(RelationManagerClassHere::class) I think
I'll try that, thanks !
@Dan Harrin I see your filamentphp badge, do you think it would be a good idea to mention this in the Code quality tips ?
Someone pointed me to that page in this thread to reuse schema because I wanted to avoid field repetition between Form, Relationship Manager and createOptionForm.
Or should relationship automatically be hidden when they conrespond to the currently displayed relationship manager ?
@Dan Harrin Ohh, I see you're co-creator, nice ♥️
If you think this is a good idea, I can open this as a Github Issue / Discussion to improve the docs
Forms\Components\Select::make('ai_provider_id')
->label('Développeur')
->searchable()
->columnSpan('full')
->relationship('aiProvider', 'name')
->createOptionForm([
Forms\Components\TextInput::make('name')
->label('Nom')
->required(),
])
->preload()
->default(fn ($livewire) => $livewire instanceof \Filament\Resources\RelationManagers\RelationManager
? $livewire->getOwnerRecord()->getKey()
: null),
theres no need to do this though, Filament automatically associates the correct foreign key
you can remove the component completely
the docs are open source so you can submit a PR to the repo for them 👍
Good, I'll open a PR to improve the Code quality tips page in that case.
Hopefully it gets merged 👌
its also in the v3 docs