F
Filament17mo ago
toeknee

Settings placeholders Dynamically?

We can set the field content, but can we set the placeholders anyway, other than being reactive and getting the data baed on the selected ID. As it stands I'm having to do more queries than I would like when someone selects a user in a list. I am setting placeholers so they can see the details of that user and they can override specific details if they wish.
5 Replies
ZedoX
ZedoX17mo ago
I once solved this problem using a disabled textarea On the select
->afterStateUpdated(function ($state, Closure $set) {
if (blank($state)) {
$set('selected', '');
return;
}
$user = User::find($state, ['first_name', 'last_name', 'mobile', 'email']);
$set('selected', join("\n", [
'Name: ' . $user->name,
'Mobile: ' . $user->mobile,
'Email: ' . ($user->email ?? '-'),
]));
})
->afterStateUpdated(function ($state, Closure $set) {
if (blank($state)) {
$set('selected', '');
return;
}
$user = User::find($state, ['first_name', 'last_name', 'mobile', 'email']);
$set('selected', join("\n", [
'Name: ' . $user->name,
'Mobile: ' . $user->mobile,
'Email: ' . ($user->email ?? '-'),
]));
})
Disabled textarea
Textarea::make('selected')
->disableLabel()
->visible(fn ($state) => filled($state))
->rows(3)
->default('')
->dehydrated()
->disabled(),
Textarea::make('selected')
->disableLabel()
->visible(fn ($state) => filled($state))
->rows(3)
->default('')
->dehydrated()
->disabled(),
toeknee
toekneeOP17mo ago
Interesting
toeknee
toekneeOP17mo ago
Thank you! Any suggestions on how to update like reactive works when you delete an item from a repeater?
LeandroFerreira
LeandroFerreira17mo ago
hum I don't know
Want results from more Discord servers?
Add your server