@maticl
@maticl
FFilament
Created by @maticl on 2/5/2025 in #❓┊help
Pass data from parent modal to child
Figured out you can get it from mountedtableactions:
->fillForm(function (Component $livewire) {
dd($livewire->mountedTableActionsData[0]);
// Need parent data here
})
->fillForm(function (Component $livewire) {
dd($livewire->mountedTableActionsData[0]);
// Need parent data here
})
4 replies
FFilament
Created by @maticl on 2/5/2025 in #❓┊help
Table action with form - confirmation before submit
Hey, thanks for the help, it works now 🙈 missread the docs... Hijacking the thread, is there a way to pass parent form data into child? Currently having issues with this.
6 replies
FFilament
Created by @maticl on 11/8/2024 in #❓┊help
RelationManager table action always injects the same record
So after some more debugging, i found the issue. It was in the User relationship to the auditLogs. Since I have two morphs fields in auditLog (parent and related), this specific relationship queries by both of them:
public function allAuditLogs(): MorphMany
{
return $this->morphMany(AuditLog::class, 'parent')
->orWhere(function ($query) {
$query->where('related_type', $this->getMorphClass())
->where('related_id', $this->id);
});
}
public function allAuditLogs(): MorphMany
{
return $this->morphMany(AuditLog::class, 'parent')
->orWhere(function ($query) {
$query->where('related_type', $this->getMorphClass())
->where('related_id', $this->id);
});
}
This was not working with the table actions. The table itself was OK, just the actions were not working. I don't specifically like this solution, as it seems wrong, but I don't have the time to figure out the proper solution. Any tips are welcome. I changed it to the following, and now it's working:
public function allAuditLogs(): MorphMany
{
return $this->morphMany(AuditLog::class, 'parent')
->where(function ($query) {
$query->where(function ($query) {
$query->where('related_type', $this->getMorphClass())
->where('related_id', $this->id);
})->orWhere(function ($query) {
$query->where('parent_type', $this->getMorphClass())
->where('parent_id', $this->id);
});
});
}
public function allAuditLogs(): MorphMany
{
return $this->morphMany(AuditLog::class, 'parent')
->where(function ($query) {
$query->where(function ($query) {
$query->where('related_type', $this->getMorphClass())
->where('related_id', $this->id);
})->orWhere(function ($query) {
$query->where('parent_type', $this->getMorphClass())
->where('parent_id', $this->id);
});
});
}
3 replies