F
Filament10mo ago
Fasna

How to set the value of the relationship form based on the parent form?

I'm trying to pre-fill a relationship form based on the parent form. Tried with the following, but the form field inside the relationship is not populated. (Here slug field inside the schema of relationship)
TextInput::make('title')
->live()
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', $state))

TextInput::make('slug')
TextInput::make('title')
->live()
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', $state))

TextInput::make('slug')
2 Replies
Fasna
FasnaOP10mo ago
thank you, that solved the issue I had to enter the relationship name followed by a period and the field name, then it worked.
TextInput::make('title')
->live()
->afterStateUpdated(fn (Set $set, ?string $state) => $set('body.slug', $state))

TextInput::make('slug')
TextInput::make('title')
->live()
->afterStateUpdated(fn (Set $set, ?string $state) => $set('body.slug', $state))

TextInput::make('slug')
Assume the body is relationship name
Want results from more Discord servers?
Add your server