F
Filament5mo 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
Fasna4mo 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