-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
itemOptions don't apply for yii\boostrap\ActiveField::checkboxList and ::radioList #6527
Comments
all apply: https://github.com/yiisoft/yii2-bootstrap/blob/master/ActiveField.php#L257 |
I want to add attribute for fields: $form = yii\bootstrap\ActiveForm::begin();
...
$form->field($model, 'fieldName')->radioList($list, ['itemOptions' => ['data-bind' => 'checked:fieldName']]) I expect:
But getting:
|
yes, it bugged behavior in bootstrap, but u must use $form->field($model, 'fieldName')->radioList($list, ['item' => function() {
return '<div class="checkbox">' . Html::checkbox($name, $checked, ['label' => $label, 'value' => $value, 'data-bind' => 'checked:fieldName']) . '</div>';
}]); |
But if I use $form = yii\widgets\ActiveForm::begin(); |
Maybe worth to correct the code? } elseif (!isset($options['item'])) {
$itemOptions = isset($options['itemOptions']) ? $options['itemOptions'] : [];
$options['item'] = function ($index, $label, $name, $checked, $value) use ($itemOptions) {
return '<div class="radio">' . Html::radio($name, $checked, array_merge($itemOptions, ['label' => $label, 'value' => $value])) . '</div>';
};
} |
Checked on 2.0.5 still doesn't work, but it works with |
+1 |
This is because yii\bootstrap\ActiveField uses custom formatter by overriding 'item' option: https://github.com/yiisoft/yii2-bootstrap/blob/master/ActiveField.php#L269 (look near Implementation contradicts the documentation, where is said:
Indeed, options of Either documentation, or bootstrap radioList() implementation should be fixed. |
Issue moved to yiisoft/yii2-bootstrap#106 |
$options['itemOptions']
is not used for generation inputs.https://github.com/yiisoft/yii2-bootstrap/blob/master/ActiveField.php#L254
https://github.com/yiisoft/yii2-bootstrap/blob/master/ActiveField.php#L280
#5483
The text was updated successfully, but these errors were encountered: