M
M
Mikha Pankratov2015-03-12 18:35:37
Yii
Mikha Pankratov, 2015-03-12 18:35:37

ActiveForm begin - how to assemble the desired form?

Active Form

<?php $form = ActiveForm::begin([
//        'enableClientValidation' => true,
//        'enableAjaxValidation' => true,
            'id' => 'form-signup',
//            'fieldConfig' => [
//                'template' => '<div class="r-f-pp">{label}{input}</div>',
//            ],
        ]); ?>
    <div class=r-f-b> 
        <div class=r-f-pp> 
            <?= Html::activeLabel($model, 'name') ?>
            <?= $form->field($model, 'username') ?>    
    </div> 
        </div> 
    <div class=r-f-b>
        <div class=r-f-pp-l>
            <?= Html::activeLabel($model, 'email') ?>
            <?= $form->field($model, 'email') ?>
        </div>
    </div>
    <div class=r-f-b> 
        <div class=r-f-pp>
            <?= Html::activeLabel($model, 'password') ?>
            <?= $form->field($model, 'password')->passwordInput() ?>
        </div>
    </div>
    <div class=r-f-pp-h> 
        <?= Html::submitButton('Готово!', ['class' => 'card-button blue', 'name' => 'signup-button']) ?>
    </div>
        <?php ActiveForm::end(); ?>

The form that I collect, as you can see, the form is unsuccessful. I'm asking for help and a kick in the right direction.
<!--            <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>-->

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikha Pankratov, 2015-03-13
@frmax

Hello,
I'm trying to make something like this.

<div class=reg-block id=reg-block> 
        <form class=reg-form-popup> 
            <div class=r-f-b> 
                <div class=r-f-pp> 
                    <label for=name> <span>Ваше имя</span><input id=sinup-name type=text name=name></label> 
                </div>
                <div class=r-f-pp> 
                    <label for=last-name> <span>Фамилия</span> <input id=sinup-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 type=password name=password></label> 
                </div>
                <div class=r-f-pp-h> <button class="card-button blue" >Готово!</button> </div>
            </div> 
        </form>
    </div>

Almost done, look what happened
<div class=reg-block id=reg-block> 
     <?php $form = ActiveForm::begin([
            'action' => '/site/singup',
            'method' => 'POST',
            'id' => 'form-signup',
            'options' => ['class' => 'reg-from-popup'],
     ]); ?>
    <div class=r-f-b>
        <?= $form->field($model, 'username', [
        'inputTemplate' => '<div class=r-f-pp> 
                    <label for=name> <span>Ваше имя</span>{input}</label></div>',
    ])->label(false)->error(false); ?>    
        <?= $form->field($model, 'lastname', [
        'inputTemplate' => '<div class=r-f-pp> 
                    <label for=last-name> <span>Фамилия</span> {input}</label></div>',
    ])->label(false)->error(false); ?>    
    </div>
        <?= $form->field($model, 'email', [
        'inputTemplate' => '<div class=r-f-b>
                <div class=r-f-pp-l> 
                    <label for=mail> <span>Электронная почта</span> {input}</label> 
                    <p class=p-att>Нужна чтобы вы смогли войти на сайт. Отправлять ничего не будем.</p> 
                </div> 
            </div> ',
    ])->label(false)->error(false); ?>
    <div class=r-f-b>
        <?= $form->field($model, 'password', [
        'inputTemplate' => ' 
                <div class=r-f-pp> 
                    <label for=pwd> <span>Пароль</span> {input}</label>
                </div>',
    ])->passwordInput()->label(false)->error(false); ?>
        <div class=r-f-pp-h>
            <?= Html::submitButton('Готово!', ['class' => 'card-button blue', 'name' => 'signup-button']) ?>
        </div>
        
    </div>
        
        <?php ActiveForm::end(); ?>
</div>

It only displays its classes, here is the html....which is displayed in the form
<div class=r-f-b>
        <div class="form-group field-signupform-username required">
<div class=r-f-pp> 
             <label for=name> <span>Ваше имя</span><input type="text" id="signupform-username" class="form-control" name="SignupForm[username]"></label></div>
</div>

I don’t understand how to get rid of, or how to make it not interfere with my layout

S
Sergey, 2015-03-13
@butteff

It's not clear what you want to do.
Learn how to work with forms , make your own validation rules, in the view file add the html code you need with the tags you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question