F
Filament16mo ago
N1XN

TextInput with Relation best practice?

How do you guys manage relational Forms? As you can see here I want to populate the city on a relational model (address). With this code everything works fine, but I am not sure if this is best practice?
TextInput::make('address.city')
->label('Stadt')
->hint('Geben Sie die Stadt ein.')
->formatStateUsing(function (Model $record) {
return $record->address()->first()?->city;
})
->required(),
TextInput::make('address.city')
->label('Stadt')
->hint('Geben Sie die Stadt ein.')
->formatStateUsing(function (Model $record) {
return $record->address()->first()?->city;
})
->required(),
1 Reply
Want results from more Discord servers?
Add your server