Is it possible to do a dynamic hint action?

Hello, I'm trying to add a hint action to a text input which would return a base url defined in the config + the value of the TextInput at the end.

TextInput::make('url')
->hintAction(
Action::make('goToUrl')
->url(function () {
// this should return a base url with the input value attached to the end
})
)

As an example, let's say my base url is "www.test.com" and then I input something into the "url" TextInput, like /users. The end result would be that the hint action url should be "www.test.com/users".

I'm not sure how to live update the hint action. Is there a way?
Solution
Forms\Components\TextInput::make('url')
    ->live(debounce: 500)
    ->hintAction(
        Forms\Components\Actions\Action::make('goToUrl')
            ->url(fn (Forms\Get $get): string => str('https://test.com/')->append($get('url')))
    )

You can also use onBlur: true
Was this page helpful?