Answer the question
In order to leave comments, you need to log in
[[+content_image]]
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],
];
}
class UserModal extends Widget
{
public function run()
{
$signup_form = new SignupForm();
return $this->render('user-modal',[
'signup_form'=>$signup_form,
]);
}
}
<?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(); ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question