[Bug]: Manage team relationship members
eele94 opened this issue · 4 comments
eele94 commented
What happened?
Manage team relationship members is not working when using an select.
How to reproduce the bug
Call to a member function isRelation() on null
public static function getSchema(): array
{
return [
TextInput::make('title')
->required(),
Textarea::make('description')
->autosize(),
Toggle::make('urgent'),
TextInput::make('progress')->numeric(),
Select::make('team')
->relationship('team', 'name')
->multiple()
->options(Filament::getTenant()->allUsers()->pluck('name', 'id'))
->searchable(['name', 'email'])
->preload()
];
}
<?php
namespace App\Filament\Pages;
use App\Enums\TaskStatus;
use App\Models\Task;
use Filament\Actions\CreateAction;
use Illuminate\Database\Eloquent\Model;
use Mokhosh\FilamentKanban\Pages\KanbanBoard;
class TasksKanbanBoard extends KanbanBoard
{
public bool $disableEditModal = false;
protected static ?string $title = 'Tasks';
protected static ?string $slug = 'tasks';
protected static string $model = Task::class;
protected static string $statusEnum = TaskStatus::class;
protected static string $headerView = 'tasks-kanban.kanban-header';
protected static string $recordView = 'tasks-kanban.kanban-record';
protected static string $statusView = 'tasks-kanban.kanban-status';
public function mount(): void
{
$this->form->model(static::$model);
}
public function getHeaderActions(): array
{
return [
CreateAction::make()
->model(self::$model)
->form(self::$model::getSchema())
->mutateFormDataUsing(fn ($data) => array_merge($data, [
'user_id' => auth()->id(),
])),
];
}
protected function getEditModalFormSchema(?int $recordId): array
{
return self::$model::getSchema();
}
protected function getModel(int $recordId): Model
{
return self::$model::findOrFail($recordId);
}
protected function getEditModalRecordData(int $recordId, array $data): array
{
return $this->getModel($recordId)->toArray();
}
protected function editRecord(int $recordId, array $data, array $state): void
{
static::$model::find($recordId)->update($data);
}
}
Package Version
2.4.0
PHP Version
8.3
Laravel Version
10
Which operating systems does with happen with?
Linux
Which browsers does with happen with?
Chrome
Notes
No response
mokhosh commented
Nice catch!
Fixed in https://github.com/mokhosh/filament-kanban/releases/tag/v2.5.0
eele94 commented
Thanks man, however it's still not working for me.
Creating a Task is working, but when updating it's not using the state of the form and instead has the previous state.
mokhosh commented
I've added tests, and have tested manually, and it worked.
Can you please provide a reproduction repository, or a failing test, so I can see where your issue is?
eele94 commented
Thanks for testing. I still had a mount function to set a model which I should've removed