© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
5 replies
prowler

Grouping by parent in a Select component

I have a 3 models -
Brief
Brief
,
CustomOption
CustomOption
and
CustomOptionType
CustomOptionType
. Each
Brief
Brief
belongs to many
CustomOptionType
CustomOptionType
with a pivot table -

    public function customOptionTypes(): BelongsToMany
    {
        return $this->belongsToMany(CustomOptionType::class, 'brief_custom_option_types', 'brief_id', 'custom_option_type_id')
            ->withTimestamps();
    }
    public function customOptionTypes(): BelongsToMany
    {
        return $this->belongsToMany(CustomOptionType::class, 'brief_custom_option_types', 'brief_id', 'custom_option_type_id')
            ->withTimestamps();
    }


And each CustomOptionType belongs to CustomOption -

  public function customOption(): BelongsTo
  {
      return $this->belongsTo(CustomOption::class);
  }
  public function customOption(): BelongsTo
  {
      return $this->belongsTo(CustomOption::class);
  }


Now, in
BriefResource.php
BriefResource.php
- I'd like to group this Select component by the 'parents' of the custom option types -

 Select::make('Custom Options')
                        ->label('Custom Options')
                        ->preload()
                        ->searchable()
                        ->relationship('customOptionTypes', 'name')
                        ->multiple(),
 Select::make('Custom Options')
                        ->label('Custom Options')
                        ->preload()
                        ->searchable()
                        ->relationship('customOptionTypes', 'name')
                        ->multiple(),


I know you can group them when explicitly using the
->options()
->options()
function, but in this case im loading those directly via a relationship so im not sure how to achieve that.

Thanks in advance.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Grouping by enum
FilamentFFilament / ❓┊help
3y ago
Additional data in a Select component?
FilamentFFilament / ❓┊help
2y ago
Select filter grouping options in relation filter
FilamentFFilament / ❓┊help
3y ago
Value in Select component
FilamentFFilament / ❓┊help
3y ago