Yii2 - Dropdownlist Not Being Submitted In Post

I’m new to yii and i’m using a dropdownlist to list some products that i need in my controller.

Here is the view code:

<?php $form = ActiveForm::begin(); ?>

    <?= $form->field($company, 'dot_com_name')->staticInput() ?>

<p> You have:<p>

<?php echo $balance?>   

    <?= $form->field($product,'dot_prod_id')->dropDownList(ArrayHelper::map

(Product::find()->where(['dot_prod_com' =>$company->dot_com_id])->all(), 

'dot_prod_id','dot_name'), ['prompt' => 'Select'])?>

<div class="form-group">

 <?= Html::submitButton('Redeem', ['class' => 'share']) ?>


<?php ActiveForm::end(); ?>

In my controller

$product = new Product;

            if ($product->load(Yii::$app->request->post())){

        echo "<script type ='text/javascript'> alert('ID USER: ".$product->dot_prod_id."');</script>";

        echo $product->dot_prod_id;

The alert and the echo doesn’t return nothing… Just blank spaces. Help please!!

For massive assignment using model->load, model attributes must be set safe. Setup these attributes implicitly as safe in your model rules, in case you do not have other rules or scenarios set for these:

   public function rules() {

      return [

          [['dot_prod_id'], 'safe'],



Thanks Kartik! It works :) You can put it has solved.