I'm trying to get value of selected dropdown menu from signup form. i need to store that value in db. dropdown code is.
<?= $form->field($model, 'sex')->dropDownList(['1' => 'Male', '2' => 'Female'],['prompt'=>'Select Gender...'] )?>
I have tried with property 'sex[]' here. but it didn't help.
i have tried in controller with post request.
$post=Yii::$app->request->post();
$chosen = Yii::$app->request->post('sex', '');
print_r($chosen);
print_r($post->sex);
echo "1:".$this->sex;
echo "<br>";
echo "2:".$this->sex;
echo "<br>";
echo "3:".$this->sex[0];
echo "<br>";
echo "4:".$this->sex[1];
echo "<br>";
but non of these printed the vlaue in post submitted. it contains the value for sex. here is the print_r($post) result [sex]=>1 but if is use'sex[]'in dropdown it shows something like [sex]=>array( [0]=>1)