F
Filament15mo ago
Xiquita

Text Input tel() or email()

Hello friends, is there any way to accept cell phone and email in the same text input? Thanks
10 Replies
S. Mert ÖZTÜRK
S. Mert ÖZTÜRK15mo ago
TextInput::make('text') ->email() // or ->tel() // or
Xiquita
XiquitaOP15mo ago
but this only accepts one of them
S. Mert ÖZTÜRK
S. Mert ÖZTÜRK15mo ago
Yeah sure, how can imagine one input for email and phone. like this ? [email protected]
Xiquita
XiquitaOP15mo ago
no, what I want is for the user to enter an email or mobile phone
S. Mert ÖZTÜRK
S. Mert ÖZTÜRK15mo ago
user can write email or phone, selectable. But you want to control on save is it need to be email or phone right if you want to do this, you need to save before mutation for control
Xiquita
XiquitaOP15mo ago
ho ok
S. Mert ÖZTÜRK
S. Mert ÖZTÜRK15mo ago
in your edit/create resource page; protected function mutateFormDataBeforeSave(array $data): array { $userInputForControl = $data['phone_or_email']; //make your text control is it phone or email here return $data; }
Xiquita
XiquitaOP15mo ago
ok thanks
S. Mert ÖZTÜRK
S. Mert ÖZTÜRK15mo ago
and little plus, if you found an error on input you can use notification; Notification::make() ->title("Please provide an email or phone number") ->danger() ->send();
Xiquita
XiquitaOP15mo ago
ho ok

Did you find this page helpful?