© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
6 replies
zen69

Select value when using allowHtml

Hello! I'm using allowHtml on my selection with a relationship.
My issue is, since I'm rendering the options with the user avatar and name, The value passed is no longer the id that I need, but the whole Html used to render the options.
My question is how can I get just the value without the html please:

Select::make('user_id')
     ->label(fn() => __('Collaborateur'))
     ->allowHtml()
     ->relationship(
         name: 'user',
         titleAttribute: 'name',
         modifyQueryUsing: fn(Builder $query) =>                       $query>withoutRoles([
              config('filament-shield.super_admin.name'),               config('filament-shield.panel_user.name')
             ])
                                        
        )->searchable(['name', 'email'])
         ->searchPrompt(__('Rechercher par nom ou email'))
         ->getOptionLabelFromRecordUsing(fn(Model$record) =>                                  Blade::render(
                  '<x-filament::avatar
                      src="' . filament()>getUserAvatarUrl($record) . '"
                      size="sm"
                      class="inline mr-2"
                    /> ' . $record?->name . ' - ' . $record->email
               )
           )->required()
Select::make('user_id')
     ->label(fn() => __('Collaborateur'))
     ->allowHtml()
     ->relationship(
         name: 'user',
         titleAttribute: 'name',
         modifyQueryUsing: fn(Builder $query) =>                       $query>withoutRoles([
              config('filament-shield.super_admin.name'),               config('filament-shield.panel_user.name')
             ])
                                        
        )->searchable(['name', 'email'])
         ->searchPrompt(__('Rechercher par nom ou email'))
         ->getOptionLabelFromRecordUsing(fn(Model$record) =>                                  Blade::render(
                  '<x-filament::avatar
                      src="' . filament()>getUserAvatarUrl($record) . '"
                      size="sm"
                      class="inline mr-2"
                    /> ' . $record?->name . ' - ' . $record->email
               )
           )->required()
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

Error in documentation or code ( Select->allowHtml( ) )
FilamentFFilament / ❓┊help
2y ago
Select field allowHtml does not render <img> tags.
FilamentFFilament / ❓┊help
2y ago
MorphToSelect with allowHtml
FilamentFFilament / ❓┊help
3y ago