Как только отключаю, то все записывает.
Код: Выделить всё
public function actionRegistration()
{
$model = new user();
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
$model->save();
if($model->save()){echo 2;}else{echo 3;}//выдает 3
}
}
return $this->render('user', [
'model' => $model,
]);
}
Код: Выделить всё
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "User".
*
* @property integer $id
* @property string $username
* @property string $auth_key
* @property string $password_hash
* @property string $password_reset_token
* @property string $email
* @property integer $role
* @property integer $status
* @property integer $created_at
* @property integer $updated_at
* @public $verifyCode;
*/
class User extends \yii\db\ActiveRecord
{
public $verifyCode;
public static function tableName()
{
return 'User';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['username', 'auth_key', 'password_hash', 'email'], 'required'],
[['role', 'status', 'created_at', 'updated_at'], 'integer'],
[['username', 'password_hash', 'password_reset_token', 'email'], 'string', 'max' => 255],
[['auth_key'], 'string', 'max' => 32],
//['verifyCode', 'captcha']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'username' => 'Логин',
'auth_key' => 'Пароль',
'password_hash' => 'Пароль повторим на всякий случай',
'password_reset_token' => 'Password Reset Token',
'email' => 'Мыло',
'role' => 'Role',
'status' => 'Status',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
'verifyCode' => 'Код с картинки',
];
}
}
Код: Выделить всё
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\captcha\Captcha;
/* @var $this yii\web\View */
/* @var $model app\models\user */
/* @var $form ActiveForm */
?>
<div class="insex">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'username') ?>
<?= $form->field($model, 'auth_key') ?>
<?= $form->field($model, 'password_hash') ?>
<?= $form->field($model, 'email') ?>
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
]) ?>
<div class="form-group">
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div><!-- insex -->