Assign record for EditAction

Hi there. I have a custom page where I'm building a standard HTML table and want to have an EditAction associated with each row in the table, but I cannot figure out how to assign the record to the action. I've tried many different ways with no success. I'm sure it's something simple, but I can't seem to figure out what I'm missing.

Currently, when I click the button I get an error saying the record is null. My current code looks like this
Relevant part of the blade file:
@foreach ($this->open_enrollments as $open_enrollment)
    <tr>
        <td>
            {{ ($this->assignStudent)(['enrollment' => $open_enrollment]) }}
        </td>
    </tr>
@endforeach


Relevant parts of the class:
namespace App\Filament\Pages;

...
use App\Models\Enrollment;
...

class MyClasses extends Page
{
    public $open_enrollments;

    #[Computed]
    public function enrollments()
    {
        $user = Auth::user();
        $user->loadMissing(['enrollments.course.nextEvent']);
        return $user->enrollments;
    }

    public function assignStudent(): Action {
        return EditAction::make('assignStudent')
            ->label('Assign Student')
            ->record(function (array $arguments) {
                return $arguments['enrollment'] ?? null;
            })
            ->schema([
                Select::make('student_id')
                    ->createOptionForm(fn (Schema $schema) => StudentForm::configure($schema, auth()->id()))
                    ->relationship('student', 'id', function(Builder $query) {
                        return $query->where('user_id', auth()->id());
                    })
            ]);
    }

    public function mount() {
        $this->open_enrollments = collect();

        $this->enrollments->each(function (Enrollment $enrollment) {
            if (!$enrollment->student_id) {
                $this->open_enrollments->push($enrollment);
            }
        });
    }
}
Screenshot_2025-08-04_074217.png
Was this page helpful?