F
Filamentβ€’2mo ago
Sjoerd24

Editing select label with pivot values

I have this form in a repeater form:
Forms\Components\Select::make('user_id')
->label(__('User'))
->relationship('user', 'name')
->live(onBlur: true)
->disabled(fn($record) => $record?->is_absent)
->distinct()
->disableOptionsWhenSelectedInSiblingRepeaterItems()
Forms\Components\Select::make('user_id')
->label(__('User'))
->relationship('user', 'name')
->live(onBlur: true)
->disabled(fn($record) => $record?->is_absent)
->distinct()
->disableOptionsWhenSelectedInSiblingRepeaterItems()
Now I am trying that the text "(absent)" appears after the username if is_absent ==true. I tried it with formatStateUsing and getOptionLabelFromRecordUsing(), but I just can't get it to work because i need the values from the relationship and the current (pivot) record. I am probably doing something stupid, but could someone point me in the right direction?
4 Replies
awcodes
awcodesβ€’2mo ago
Does your relationship return with the pivot columns? Ie, ->withPivot() in the relationship definition on the model.
Sjoerd24
Sjoerd24β€’2mo ago
Yeah it does, the ->disabled part works perfectly also. I just don't know how to edit the label. Or to give some other visual sign that this user has a vacation or sth planned.
Sjoerd24
Sjoerd24β€’2mo ago
This is how it looks currently, what i want is also add behind the name a text (absent) or sth so that it is clear why the user is disabled.
No description
Sjoerd24
Sjoerd24β€’2mo ago
love your table repeater btw 😎
Want results from more Discord servers?
Add your server
More Posts
Can I add multiple menu items for same resource e.g. My Contacts & All Contacts?When selecting any menu item, it will open ContactResource and a filter will be added based on the lConditionally rendering an icon in TextColumnI have a situation where the value of a cell could be "true" or anything else. How can I render an iUsing Filament with Tailwind PrefixIs it possible to use filament when we are using the tailwind prefix (eg in our case we are using 'tModify url/query string when action modal opensLet's say that I have a simple `CustomerResource` at `/admin/customers`, when I open the create modacss has preload warning aftter adding to ApplServiceProvider with hook. How to fix this?domain. com/build/assets/app-BHJDlZSC.css was preloaded using link preload but not used within a few->sortable(), searchable(), and pagination not working with LivewireAdding ->sortable() and searchable() in columns adds the sort icon and the search bar but clicking tCustom Filament-Excel Exporthola, podrian ayudarme con un export donde debo mostrar las edades de los usuarios y familiares perMulti Tenancy within multi tenancyHi! Has anyone ever tried to chain tenancies? Like each customer has departments that have projectsPrevent pagination page numbers overflowingHaving an issue with pagination where the page numbers are overflowing into the "Per page" which meaInject an HttpClient into a Filament PageHello devs, so I have an HttpClient class that I have created and implemented some methods. I want t