[[+content_image]]
S
S
Sergey Beloventsev2018-07-13 14:57:17
Yii
Sergey Beloventsev, 2018-07-13 14:57:17

Why is there an error with compare?

Here is the model

class SignupForm extends Model
{
    public $email;
    public $password;
    public $password_copy;

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['type', 'email', 'password', 'password_copy'], 'required'],
            ['email', 'email'],
            ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'Данный Email уже используется.'],
            ['type', 'integer'],
            ['password', 'string', 'min' => 6],
            ['password_copy', 'compare', 'compareAttribute' => 'password', 'message' => 'Пароли не совпадают','skipOnError' => true],
        ];
    }

I form the form in the widget
class UserModal extends Widget
{
    public function run()
    {
        $signup_form = new SignupForm();
        return $this->render('user-modal',[
            'signup_form'=>$signup_form,
        ]);
    }
}

here is the widget view
<?php $form = ActiveForm::begin(['action' => Url::to(['site/signup'])]); ?>
        <ul class="user__type">
            <?= $form->field($signup_form, 'type', ['template' => 'clean'])->radioList($signup_form->typeArr, [
                'item' => function($index, $label, $name, $checked, $value) {
                    $checked_attr = $checked ? 'checked="checked"' : '';
                    return '<li><label><input type="radio" name="'.$name.'" value="'.$value.'" '.$checked_attr.'>'.$label.'</label></li>';
                }
            ]) ?>
        </ul>
        <?= $form->field($signup_form, 'email')->textInput(['placeholder' => 'Электронная почта'])->label(false) ?>
        <?= $form->field($signup_form, 'password')->passwordInput(['placeholder' => 'Пароль'])->label(false) ?>
        <?= $form->field($signup_form, 'password_copy')->passwordInput(['placeholder' => 'Повторите пароль'])->label(false) ?>
<button class="button button_wide form--button is-disabled" onclick="fbq('track', 'Lead');" data-next-button>Зарегистрироваться</button>
       <?php ActiveForm::end(); ?>

but here is such nonsense
https://prnt.sc/k60ymj
the question is why.
And this is only with client validation.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question