© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
wally

set value in form field when there is a relationship

Friends I have a problem...

I have a resource that performs an API query, the data is returned normally and I $set the value obtained in the query in its respective form field.

" $set('zip_code', $cnpjData['cep']);
$set('street', Str::title($cnpjData['logradouro']) );
$set('number', $cnpjData['numero']);
$set('district', Str::title($cnpjData['bairro']));
$set('city', Str::title($cnpjData['municipio']));"

However, in this form I have a relationship with an address table

"Fieldset::make('Informações de Endereço')
->relationship('company_address')
->schema([

Cep::make('zip_code')
->label('CEP')
->columnSpan(1),

TextInput::make('street')
->label('Logradouro')
->columnSpan(2)
->required()
->maxLength(255),"


If I remove the ( ->relationship('company_address')) the information is filled in normally when I have the searched data returned, However, if I leave this option, when I search for data in the API, these fields are not filled in.
Can someone help me?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Setting value of relationship form field via $set closure
FilamentFFilament / ❓┊help
3y ago
Remove value when form field is hidden
FilamentFFilament / ❓┊help
3y ago
Set form field value from outside the form
FilamentFFilament / ❓┊help
3y ago
Set value without a field
FilamentFFilament / ❓┊help
2y ago