Search code examples
laravellaravel-filamentfilamentphp

Filament: TextInput select field


In filament 3, how to make the TextInput so that when user click on it, it will select all the value in the input field?

The behavior will be similar like input.select()

https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select


Solution

  • TextInput::make('categories')
    ->extraInputAttributes(['onClick' => 'this.select();'])
    

    Add extraInputAttributes attribute to your TextInput.

    For more please follow https://filamentphp.com/docs/3.x/forms/fields/getting-started#adding-extra-html-attributes