Open dev-mraj opened 8 years ago
open checkboxList
guide say:
// поддерживает выбор нескольких значений:
echo $form->field($model, 'items[]')->checkboxList(['a' => 'Item A', 'b' => 'Item B', 'c' => 'Item C']);
you read guide?
i've already tried this thing.
<?
use yii\helpers\ArrayHelper;
$cats=Category::find()->all();
echo $form->field($model, 'categoriesIds[]')->checkboxList(ArrayHelper::map($cats, 'id', 'name'));
?>
Unable to reproduce it. @dev-mraj would be great if you'll provide a clear way reproducing the issue.
@samdark
Don't use checkboxList. use checkbox with loop its reproducible bug.
It seems that it had already been fixed in https://github.com/yiisoft/yii2/issues/11973 but then reverted because of BC break. So, this example should be removed from the documentation:
// allow multiple items to be checked:
echo $form->field($model, 'items[]')->checkboxList(['a' => 'Item A', 'b' => 'Item B', 'c' => 'Item C']);
What steps will reproduce the problem?
Lets talk in code directly.
i've categories's values but it don't check checkboxes based on this array, its saving values as well properly.
What is the expected result?
When database has (categoriesIds) has array like [1,2] then checkbox state sholud be checked
(i think as previously in yii1 it was working but not sure)
What do you get instead?
its not checked at all
Additional info
BaseHtml::getAttributeValue
Solution