Hidden value filled by other input

Hi! What would be the best way to have InputA in the form visible where the user can type something and have InputB hidden in the form that is populated by something from InputA. - InputA you fill in a Discord username - After typying is done you fetch the userid from the discord user - InputB (hidden in the form) will be populated with the discord userid - Create record. And InputB will be sent off as value for creating that record. What would be the right way to do so?
TextInput::make('player')->reactive()
->afterStateUpdated(function (Closure $set, $state) {
$set('uuid', $ID);
}),
TextInput::make('uuid')->hidden(),
TextInput::make('player')->reactive()
->afterStateUpdated(function (Closure $set, $state) {
$set('uuid', $ID);
}),
TextInput::make('uuid')->hidden(),
4 Replies
HiJoe
HiJoeOP2y ago
I did got it working doing this. But the player is still in the array?
array:3 [▼ // vendor\filament\filament\src\Pages\Actions\CreateAction.php:46
"server" => "minecraft_smp"
"player" => "lebatta"
"uuid" => "1abb98cd-d0e3-4d3d-8b31-27f81b92510b"
]
array:3 [▼ // vendor\filament\filament\src\Pages\Actions\CreateAction.php:46
"server" => "minecraft_smp"
"player" => "lebatta"
"uuid" => "1abb98cd-d0e3-4d3d-8b31-27f81b92510b"
]
awcodes
awcodes2y ago
If you don’t need player to be saved you can use ->dehydrated(false) so it’s not part of the data that gets saved.
HiJoe
HiJoeOP2y ago
Aaah thanks! Ill add that 🙂
HiJoe
HiJoeOP2y ago
Got it working! Also with a little hap from Dan!
array:2 [▼ // vendor\filament\filament\src\Pages\Actions\CreateAction.php:46
"server" => "minecraft_smp"
"uuid" => "1abb98cd-d0e3-4d3d-8b31-27f81b92510b"
]
array:2 [▼ // vendor\filament\filament\src\Pages\Actions\CreateAction.php:46
"server" => "minecraft_smp"
"uuid" => "1abb98cd-d0e3-4d3d-8b31-27f81b92510b"
]
Want results from more Discord servers?
Add your server