S
S
Stepan Panov2019-03-18 09:56:46
Yii
Stepan Panov, 2019-03-18 09:56:46

How to make forms in yii?

Please tell me how to implement such a layout:
5c8f3fdbcde50748410799.png
from this (At the moment):
5c8f40bd1b017548292093.png

<?= $form->field($orderForm, 'isAddressesEqual')
            ->label($orderForm->getAttributeLabel('billingAddress'))->checkbox([
                'class' => 'js-addresses-is-equal',
                'data-remeber' => true,
            ])->label('<span class="checkbox-text">'.$orderForm->getAttributeLabel('isAddressesEqual').'</span>')?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2019-03-18
@SteveP

I think this article https://yiico.ru/blog/499-shpargalka-po-formam-act...
will help you. You need to look towards the “template” parameter. I think this will help

<?php $form = ActiveForm::begin([
        'layout'=>'horizontal',
        'options' => ['class' => 'signup-form form-register1'],
        'fieldConfig' => [
             'template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}",
            'horizontalCssClasses' => [
                'label' => 'col-sm-4',
                'offset' => 'col-sm-offset-4',
                'wrapper' => 'col-sm-8',
                'error' => '',
                'hint' => '',
            ],
        ],
    ]); ?>

Or so
<?= Html::activeLabel($model, 'password') ?>
<?= Html::activePasswordInput($model, 'password') ?>
<?= Html::error($model, 'password') ?>

or

<?= Html::activeLabel($model, 'username', ['label' => 'name']) ?>
<?= Html::activeTextInput($model, 'username') ?>
<div class="hint-block">Please enter your name</div>
<?= Html::error($model, 'username') ?>

M
Maxim Timofeev, 2019-03-18
@webinar

The sentence cannot contain "layout" and the name of the backend php framework at the same time. What does yii have to do with it? Type it up about css and html.
If there are difficulties with the forms widget itself, then here:
https://www.yiiframework.com/doc/guide/2.0/en/inpu...
https://www.yiiframework.com/doc/api/2.0/yii -widge...
https://www.yiiframework.com/doc/api/2.0/yii-widge...
https://www.yiiframework.com/doc/guide/2.0/en/star...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question