Is it possible to create a TextInput component with a prefix that is a SelectInput?
I want the prefix to be a select action. A common example of this type of usage is international phone numbers (see image for example).
Would I have to create a custom component for this?
Solution:Jump to solution
```php
TextInput::make('mobile_number')
->label('Mobile Number')
->required()
->prefixAction(...
16 Replies
You can have
prefixAction()
and then pass an action with a form component in it to be a select field.!! thanks i will give it a shot
This does not seem to work :( Not only is an icon required (it gives me an error if i dont give it one), the select input does not show up at all.
It works for me!
D:
the action should be
Filament\Forms\Components\Actions\Action
I was just gonna say that I'm using
use Filament\Forms\Components\Actions\Action;
I'm not sure if it makes a difference but this is happening inside a wizard. I'll give it another look to see if I did anything wrong.
Would you mind passing a screenshot of how it looks for you?Interesting, the modal never shows up for me.
the rest looks similar
Solution
Yep, copy pasted the same exact code, same issues.
Regardless though, I was hoping it would serve as just a dropdown instead of modal with a dropdown.
I'll mark this as solved unless you perhaps know a way to have the button show a dropdown instead of opening a modal.
Thanks for the help anyway!!
I have another idea for this. But not sure if that's the right way to do it
I'm open to suggestions!
You can create a custom field, using filaments fields.... Like use the select and text input to create your own input field... With this, you can specifically get what you want and how you want it as you can style it
Yeah, I was thinking of doing that as well at this point. Thanks!