Answer the question
In order to leave comments, you need to log in
How to put login and registration form in the same fields and in different buttons in Laravel blade?
I often saw a form on sites where there are 2 buttons, authorization and registration, how to do this in practice? Ideally with blade + laravel.
As I understand it, a form is created, and it can send requests using different methods, but how to make the request depend on the button button?
Answer the question
In order to leave comments, you need to log in
Это делается средствами JS.
Перехват сабмита формы, и отправка данных на нужный роут.
Laravel, а тем более blade тут ни при чем.
Можно сделать и без js. Вешаете на кнопки атрибут
<input type="submit" name="login">
<input type="submit" name="register">
function handler() {
if(isset($POST['login'])){
$this->login();
}elseif(isset($POST['register'])){
$this->register();
}
}
private function login(){
//Ваша логика авторизации
}
private function register(){
//Ваша логика регистрации
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question