M
M
Mark2020-06-01 14:41:30
Yii
Mark, 2020-06-01 14:41:30

How to set data attributes in radioList Yii2?

I want to set data-attributes for each input in radioList. If in dropdown it is enough to set "options" in the array specified by the second argument, then how to do it for radioList?

Example language

$itemList = [
    'apple' => 'Яблочный крю',
    'pear' => 'Грушевый мейк',
];
$optionList = [
    'apple' => ['meta-description' => 'Описание яблочного крю'],
    'pear' => ['meta-description' => 'Описание грушевого мейка'],
];

// вызов метода для формирования формы и пр.

echo $form->field($model, "type")->dropDownList($itemList, ['options' => $optionList]); // ОК: для dropdown работает отлично
echo $form->field($model, "type")->radioList($itemList, ['options' => $optionList]); // BAD: для radioList не работает

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question