----------
Код модели Signup.php
<?php
class Signup extends Model
{
public $email;
public $password;
public function rules()
{
return[
[['email', 'password'], 'required'],
['email', 'email'],
['email', 'unique', 'targetClass' => 'app\Models\User'],
['password', 'string', 'min' => 2, 'max' => 10]
];
}
public function signup()
{
$user = new User();
$user->email = $this->email;
$user->password = $this->password;
return $user->save();
}
}
Код контроллера
<?php
public function actionSignup()
{
$model = new Signup();
if (isset($_POST['Signup']))
{
$model->attributes = Yii::$app->request->post('Signup');
if ($model->validate() && $model->signup())
{
return $this->goHome();
}
}
return $this->render('signup',
['model'=>$model]);
}
И view
<br><br>
<?php<br><br>
$form = ActiveForm::begin(['class' => 'form-horizontal']);<br><br>
$form->field($model, 'email')->textInput(['autofocus'=>true]); <br><br>
$form->field($model, 'password')->passwordInput(); <br><br>Register<br><br>
ActiveForm::end();<br><br>
А вот сама ошибка: