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
TextInput::make('text') ->email() // or ->tel() // or
Xiquita
Xiquita9mo ago
but this only accepts one of them
S. Mert ÖZTÜRK
Yeah sure, how can imagine one input for email and phone. like this ? example@example.com-50112345678
Xiquita
Xiquita9mo ago
no, what I want is for the user to enter an email or mobile phone
S. Mert ÖZTÜRK
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
Xiquita9mo ago
ho ok
S. Mert ÖZTÜRK
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
Xiquita9mo ago
ok thanks
S. Mert ÖZTÜRK
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
Xiquita9mo ago
ho ok