auto fill when i select

i want when i select debtorCompany take data from debtorCompany and fill automaticly in code and email textinput this is my code
Forms\Components\Select::make('debtor_company_id')
->relationship('debtorCompany', 'name')
->label('დებიტორის კომპანიის დასახელება')
->required(),
Forms\Components\TextInput::make('debtor_identification_code')
->label('დებიტორის საიდენტიფიკაციო კოდი')
->required(),
Forms\Components\TextInput::make('debtor_email')
->email()
->label('დებიტორი კომპანიის მეილი ')
->required(),
Forms\Components\Select::make('debtor_company_id')
->relationship('debtorCompany', 'name')
->label('დებიტორის კომპანიის დასახელება')
->required(),
Forms\Components\TextInput::make('debtor_identification_code')
->label('დებიტორის საიდენტიფიკაციო კოდი')
->required(),
Forms\Components\TextInput::make('debtor_email')
->email()
->label('დებიტორი კომპანიის მეილი ')
->required(),
Solution:
ok, you didnt mentioned it in the original message 🙂 did you add ->live()?...
Jump to solution
5 Replies
Lara Zeus
Lara Zeus3w ago
you'll need afterStateUpdated to set the other fields with the values you want from the company similler to https://filamentphp.com/docs/3.x/forms/advanced#generating-a-slug-from-a-title
gigiloouu
gigiloouuOP3w ago
yes i know that
->afterStateUpdated(function (callable $set, $state) {
// Fetch debtor data based on selected ID
if ($state) {
$debtor = DebtorCompany::find($state);

if ($debtor) {
$set('debtor_identification_code', $debtor->identification_code);
$set('debtor_email', $debtor->email);
}
->afterStateUpdated(function (callable $set, $state) {
// Fetch debtor data based on selected ID
if ($state) {
$debtor = DebtorCompany::find($state);

if ($debtor) {
$set('debtor_identification_code', $debtor->identification_code);
$set('debtor_email', $debtor->email);
}
i made something like this but its not working
Solution
Lara Zeus
Lara Zeus3w ago
ok, you didnt mentioned it in the original message 🙂 did you add ->live()?
gigiloouu
gigiloouuOP3w ago
oh wait.. ou fuck thanks bro its working now
Lara Zeus
Lara Zeus3w ago
🎉
Want results from more Discord servers?
Add your server