Is there a way to have "information-only" elements inside a form?

I've made a form with two components (see below). I'd really like to update the client's name on the screen when the user changes the client_id in the select.

Section::make('client')
->schema([
Select::make('client_id')
->options(
$this->getClientsArray()
)
->label('Client ID'),
TextInput::make('client_name')->label(Client Name)->disabled(),
]),
Solution
You can make your Select field live() and then use the ->afterStateUpdated() method to set the value of the TextInput field (which you can also mark as ->disabled() like you have in your example so that people can't update the value)

Take a look here for more on afterStateUpdated() nd here for more on the different things (including Set, which you'll need for your example) you can inject into the afterStateUpdated() closure parameter - https://filamentphp.com/docs/3.x/forms/advanced#form-component-utility-injection
Was this page helpful?