Get Relation Fieldset State / Set Outside State in Relationship Fieldset

Form resources that have fieldset relationship, how to get state that fieldset on outside?

just for example :

[
  Fieldset::make('User')
    ->relationship('users')
    ->schema([
      TextInput::make('name')
        ->required(),
    ]),
  TextInput::make('slug')
    ->dehydrateStateUsing(
        fn(string $state, callable $get) => Str::slug($get('user.name')) // <-- when get this, the value is null
      )
]


or set outside state in relationship fieldset

[
  Fieldset::make('User')
    ->relationship('users')
    ->schema([
      TextInput::make('name')
        ->required()
        ->reactive()
        ->live()
        ->afterStateUpdated( callable $set) => $set('slug', Str::slug($state))),
        // nothing happens
    ]),
  TextInput::make('slug')
    ->prefix(config('app.url') . "/profile/")
]
Solution
you should use
$set('../slug', Str::slug($state))
Was this page helpful?