Need add user id in table

Hello guys,

I am trying to save user-id in the table, but it is not saved, need this for creating and updating.

   public function actionCreate()
    {
      $product      = new Product();
      $catList      = Category::getList();
      $officeList   = Office::getOffice();
      $jewList      = Jewerly::getList();
      $this->layout = false;

      if ($product->load(Yii::$app->request->post()) && $product->save()) {
        $product->created_by = Yii::$app->user->identity->id;
        return $this->redirect(['view', 'id' => $product->id]);
      }

        return $this->renderAjax('create-modal', [
          'product' => $product,
          'catList' => $catList,
          'officeList' => $officeList,
          'jewList' => $jewList,
        ]);

    }

Thank you for any help.

var_dump($product->errors) to show what attribute doesn’t pass validation test, or try ->save(false) to skip validation

I do not have errors
print_r($product->created_by = Yii::$app->user->identity->id);
var_dump($product->errors); die();
result
1
array(0) { }
Whit save(false) same result.

      if ($product->load(Yii::$app->request->post()) && $product->validate()) {
        $product->created_by = Yii::$app->user->identity->id;
        $product->save(false);
        return $this->redirect(['view', 'id' => $product->id]);
      }