F
Filamentβ€’7mo 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β€’7mo ago
Does your relationship return with the pivot columns? Ie, ->withPivot() in the relationship definition on the model.
Sjoerd24
Sjoerd24OPβ€’7mo 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
Sjoerd24OPβ€’7mo 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
Sjoerd24OPβ€’7mo ago
love your table repeater btw 😎
Want results from more Discord servers?
Add your server