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
TextInput::make('text')
->email() // or
->tel() // or
but this only accepts one of them
Yeah sure, how can imagine one input for email and phone. like this ?
[email protected]
no, what I want is for the user to enter an email or mobile phone
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
ho ok
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;
}
ok thanks
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();
ho ok