FilamentF
Filament2y ago
Xavi

How to set selected on edit form

I have this field

Forms\Components\Select::make('billing')
  ->label(__('Datos de facturación'))
  ->options(function (RelationManager $livewire): array {
      return $livewire->ownerRecord->billings
          ->pluck('name', 'id')
          ->toArray();
  })
  ->searchable()
  ->required()

How can i set selected value on edit form (its a relationmanager), searching on user_billings table??

I try adding this

->formatStateUsing(function (UserInvoice $record, RelationManager $livewire): ?int {
    return $livewire->ownerRecord->billings->where('nif', $livewire->ownerRecord->nif)->first()?->id;
})


But it doesn't works

Thanks
Was this page helpful?