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
ZedoX2y 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
toekneeOP2y ago
Interesting
toeknee
toekneeOP2y ago
Thank you! Any suggestions on how to update like reactive works when you delete an item from a repeater?
LeandroFerreira
hum I don't know

Did you find this page helpful?