M
M
Mikha Pankratov2015-03-12 15:13:54
JavaScript
Mikha Pankratov, 2015-03-12 15:13:54

Yii2 ajax registration and authorization what is it?

Good afternoon,

I did the registration and authorization on the server, and then we decided to make a pop-up window for the login and for the registration.
How to create a form in these pop-up views and correctly submit the data. So that the validation also works and the server works out)

And then I stuck crutches - and now I'm crying with them.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Semenko, 2015-03-12
@abler98

Display the form as always in a pop-up window + Yii2 by default has support for client-side validation and ajax validation of entered data.
/views/layouts/main.php

<?php $model = new SignupForm(); ?>
<?php $this->render('/site/user/signup', ['model' => $model]); ?>

M
Mikha Pankratov, 2015-03-12
@frmax

in layout

<?php $model = new SignupForm(); ?>
    <?php $this->render('@app/views/site/user/singup.php', ['model' => $model]); ?>

in signup
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \frontend\models\SignupForm */
$this->title = 'Signup';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class=reg-block id=reg-block> 
        
        <?php $form = ActiveForm::begin([
        'enableClientValidation' => true,
        'enableAjaxValidation' => true,
        'id' => 'form-signup']); ?>
        <div class=r-f-b> 
            <div class=r-f-pp>
                <label for=name><span>Ваше имя</span>
            <?= $form->field($model, 'username') ?>    
                </label> 
            </div>
            <div class=r-f-pp>
                <label for=last-name> <span>Фамилия</span>
            <?php //= $form->field($model, 'lastname') ?>        
                </label>  
            </div>
            </div>
        <div class=r-f-b>
            <div class=r-f-pp-l>
                <label for=mail> <span>Электронная почта</span> 
                <?= $form->field($model, 'email') ?>
                    <p class=p-att>Нужна чтобы вы смогли войти на сайт. Отправлять ничего не будем.</p>
                </label>
            </div>
        </div>
            <div class=r-f-b> 
                <div class=r-f-pp> 
                    <label for=pwd> <span>Пароль</span> 
            <?= $form->field($model, 'password')->passwordInput() ?>
                    </label> 
                </div>      
            </div>
        <div class=r-f-pp-h>
            <?php //= Html::submitButton('Signup', ['class' => 'card-button blue', 'name' => 'signup-button']) ?>
            <?= Html::submitButton('Signup', ['class' => 'card-button blue', 'name' => 'Готово!']) ?>
        </div> 
        <?php ActiveForm::end(); ?>
        
        
<!--            <form class=reg-from-popup action="javascript:void(null);"> 
            <div class=r-f-b> 
                <div class=r-f-pp> 
                    <label for=name><span>Ваше имя</span><input id=name type=text name=name></label> 
                </div>
                <div class=r-f-pp> 
                    <label for=last-name> <span>Фамилия</span> <input id=last-name type=text name=lastname></label> 
                </div> 
            </div> 
            <div class=r-f-b>
                <div class=r-f-pp-l> 
                    <label for=mail> <span>Электронная почта</span> <input id=mail type=email name=login></label> 
                    <p class=p-att>Нужна чтобы вы смогли войти на сайт. Отправлять ничего не будем.</p> 
                </div> 
            </div> 
            <div class=r-f-b> 
                <div class=r-f-pp> 
                    <label for=pwd> <span>Пароль</span> <input id=pwd class=error type=password name=password></label> 
                </div>
                    <div class=r-f-pp-h> <button class="card-button blue" onclick="singup();">Готово!</button> </div> 
            </div> 
        </form>-->
    </div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question