F
Filament17mo 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

Did you find this page helpful?