Hello all!
I am getting this error:
Exactly this error occurrs in $model->save() line of my controller "actionAdd". This not are a completed method but the idea is it:
[list=1]
[*]Create New Model (ActiveRecord)
[*]Check for post to fill the model
[*]Find related data to save in the fields of the model
[*]Check $model->save(); //Error
[/list]
/**
* @throws NotFoundHttpException
*/
public function actionAdd()
{
$model = new PgcBuddiesRequest;
if ($model->load(Yii::$app->request->post())) {
//Extraemos la id del usuario a quien se le enviará el mensaje
$userTo = User::findByUsername($model->invited_username);
//Controlamos que el usuario exista
//Controlamos que no seamos nosotros mismos
$model->inviter_id = Yii::$app->user->identity->id;
$model->invited_id = $userTo->id;
/*echo "<br>a" . $model->inviter_id;
echo "<br>e" . $model->invited_id;
echo "<br>i" . $model->message;
die();*/
if($model->save()){
Yii::$app->getSession()->setFlash('buddies-add-OK', Yii::t("app", "Page_Buddies_Add_OK"));
}else{
Yii::$app->getSession()->setFlash('buddies-add-KO', Yii::t("app", "Page_Buddies_Add_KO"));
}
$this->redirect(["buddies/index"]);
}else{
throw new NotFoundHttpException("You do not have permission to stay here.");
}
}
How you can see, I tried printing these properties and are good. My activeRecord Model properties list is this:
* @property integer $id
* @property integer $inviter_id
* @property integer $invited_id
* @property integer $created_at
* @property integer $updated_at
* @property integer $status
* @property string $message
Any can help me? Its sure that this model have id property, anyway, I am not using it, I guess that "save()" is using, but this is framework code that are working in more places.