AttachAction not adding entries with global scopes.

I am trying to attach a category to a post. Categories have a global scope to hide "machine tags". I have a select field which obviously doesn't show all categories, so added removeGlobalScopes to the query… however, when I SAVE that category relationship, nothing happens – it isn't attached to the post. If I remove the scope from the model or choose a non-machine-tag category it works. Looking at the AttachAction code I can't work out why the $record ends up null as it is using Relation::noConstraints() in the action…
AttachAction::make()->recordSelectOptionsQuery(
static fn (Builder $query): Builder => $query->withoutGlobalScopes()
)
AttachAction::make()->recordSelectOptionsQuery(
static fn (Builder $query): Builder => $query->withoutGlobalScopes()
)
2 Replies
Dennis Koch
Dennis Koch3w ago
it isn't attached to the post
You checked that in the database? Or via Filament tables? If the latter: Did you remove the scope from the table query.
trovster
trovsterOP3w ago
I checked the database. And yes, the table query has the scope removed. I checked when I added one after I removed the scope and then re-added the scope and could see it on the table. If I dd() in the AttachAction $this->action() method, the $record is null…

Did you find this page helpful?