FilamentF
Filament6mo ago
o.m

Is it possible to retrieve the parent id of the relationship?

I have a repeater for questions and its like this, Questions -> options (list of questions)

 Answers::make('options')->addAction(
    fn(Forms\Components\Actions\Action $action) =
        > $action->link()
              ->label('Add an Answer')
              ->icon('heroicon-o-plus')
              ->action(function(Forms\Set $set, array $state) {
                $uuid = Str::uuid()->toString();

                $state[] = [
                  'uuid' = > $uuid,
                  'label' = > '',
                  'is_correct' = > false,
                  'disabled' = > true,  // disable newly added item to options
                  'ordinal' = > count($state) + 1,
                ];

                $set('options', $state);
              }))

I wanted to access it's parent's id so I could add it to the state[]
Was this page helpful?