How to generate Dynamic radio buttons in Yii advanced template?

This is my controller:

$Shipping = Shipping::find()->all();
foreach ($Shipping as $key => $value) {
    pr($value['name']);
}die;

O:P/
Free
Pickup
Country Wise
API

I want to generate radio button list in view with those O:P .How?

Upvotes: 0

Views: 565

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

If the radio buttons are in active form you can use active radioList

<?= $form->field($model, 'your_field')->
  radioList(ArrayHelper::map( Shipping::find()->all(), 'your_id', 'your_name')); ?>

Upvotes: 2

Related Questions