Relation Manager Resource with pivot - Custom Attach

Hi guys, i create a Relation Manager Resource with pivot. Information:
-> Invoice -> it's the Main Resource
-> Performance -> it's the Relation Manager Resource
-> they have Many to Many relationship.
-> it's work, but i need make a change.
  • I have Product table that has Many Performance, So i need on the popup show a Select for Products, when products Select filter the Performance :
    ->headerActions([
                  AttachAction::make()->label('Agregar')
                  ->form(fn (AttachAction $action): array => [
                      //$action->getRecordSelect(),
                      
                      Forms\Components\Select::make('product_id')
                          ->relationship('product','external_name')
                          ->afterStateUpdated(fn (callable $set) => $set ('start',null))
                          ->reactive()
                          ->searchable()->required(),
                      Forms\Components\Select::make('start')
                          ->options(function (callable $get){
                                              
                              $product = Product::find($get('product_id'));
                              if (!$product)
                              {
                                  return [];
                              }
                              return $product->performances()->pluck('start','id');
                          })->required()
                          
                  ]),
              ])

    The form works but when a click on Attach i got an error:
    Undefined array key "recordId"

    I imagine that to solve this I should use:
     Relation Manager Resource with pivot - Custome Attach  

    But I do not know how to do it
Was this page helpful?