F
Filament13mo 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ÜRK13mo ago
TextInput::make('text') ->email() // or ->tel() // or
Xiquita
XiquitaOP13mo ago
but this only accepts one of them
S. Mert ÖZTÜRK
S. Mert ÖZTÜRK13mo ago
Yeah sure, how can imagine one input for email and phone. like this ? [email protected]
Xiquita
XiquitaOP13mo ago
no, what I want is for the user to enter an email or mobile phone
S. Mert ÖZTÜRK
S. Mert ÖZTÜRK13mo 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
XiquitaOP13mo ago
ho ok
S. Mert ÖZTÜRK
S. Mert ÖZTÜRK13mo 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
XiquitaOP13mo ago
ok thanks
S. Mert ÖZTÜRK
S. Mert ÖZTÜRK13mo 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
XiquitaOP13mo ago
ho ok
Want results from more Discord servers?
Add your server