V
V
Voll.2016-05-20 01:36:49
Laravel
Voll., 2016-05-20 01:36:49

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

2 answer(s)
D
D', 2016-05-20
@Denormalization

Это делается средствами JS.
Перехват сабмита формы, и отправка данных на нужный роут.
Laravel, а тем более blade тут ни при чем.

Станислав Почепко, 2016-05-20
@DJZT

Можно сделать и без js. Вешаете на кнопки атрибут

<input type="submit" name="login">
<input type="submit" name="register">

При нажатии отправляете форму на какой нибудь auth/handler а в контроллере проверяете
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 question

Ask a Question

731 491 924 answers to any question