Hi
I’m trying do a table like below. I have one value and one radio button per column, what’s happening is, when i select the first or next radio buttons (except the last) return a empty value. (can u see above).
I plan to make a table:
<tr>
<td>text and radio 1 & name</td>
<td>text and radio 1 & name</td>
<td>text and radio 1 & name</td>
</tr>
My code:
Controller:
$job = new Job;
$type = Type::find()->all();
var_dump(Yii::$app->request->post('Job'));
View:
foreach($type as $value){
{
echo '<td>';
echo $value->text;
echo $form->field($job, "Type_Id")->radioList([$value->Id => $value->Name], ['class'=>'text-muted'])->label(false);
echo '</td>';
}
}
var_dump return:
If i select first or each others radio (except last):
'Type_Id' => string '' (length=0)
If i select last radio:
'Type_Id' => string '20' (length=2)
HTML Generated:
<div class="form-group field-job-Type_Id">
<input type="hidden" name="Job[Type_Id]" value=""><div id="job-Type_Id" class="text-muted"><label><input type="radio" name="Job[Type_Id]" value="14"> Blue </label></div>
<div class="help-block"></div>
</div>
<div class="form-group field-job-Type_Id">
<input type="hidden" name="Job[Type_Id]" value=""><div id="job-Type_Id" class="text-muted"><label><input type="radio" name="Job[Type_Id]" value="18"> Red </label></div>
<div class="help-block"></div>
</div>
<div class="form-group field-job-Type_Id">
<input type="hidden" name="Job[Type_Id]" value=""><div id="job-Type_Id" class="text-muted"><label><input type="radio" name="Job[Type_Id]" value="20"> Purple </label></div>
<div class="help-block"></div>
</div>
Thank you