Filament multi tenancy not cover for relationship form. how to solve?

example select input with create option form

add this code

 ->createOptionAction(function (Action $action) {
                                        $action->mutateFormDataUsing(function ($data) {
                                            $data['team_id'] = Filament::getTenant()->id;
                                    
                                            return $data;
                                        });

                                        return $action
                                            ->modalHeading('Create customer')
                                            ->modalSubmitActionLabel('Create customer')
                                            ->modalWidth('7xl');
                                    })

full code as below:

  Forms\Components\Select::make('shop_customer_id')
                                    ->relationship('customer', 'name')
                                    ->searchable()
                                    ->required()
                                    ->preload()
                                    ->live(onBlur: true)
                                
                                    ->createOptionForm([
                                        self::customerForm(),
                                    ])
                                    ->createOptionAction(function (Action $action) {
                                        $action->mutateFormDataUsing(function ($data) {
                                            $data['team_id'] = Filament::getTenant()->id;
                                    
                                            return $data;
                                        });

                                        return $action
                                            ->modalHeading('Create customer')
                                            ->modalSubmitActionLabel('Create customer')
                                            ->modalWidth('7xl');
                                    })
                                    ->native(false),

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *