Skip to content

Commit 03d8d45

Browse files
committed
Fixed preparation of js attributes
1 parent 56c937d commit 03d8d45

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/renderers/BaseRenderer.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ protected function prepareJsAttributes()
353353
$attributes = [];
354354
foreach ($this->columns as $column) {
355355
$model = $column->getModel();
356+
$inputID = str_replace(['-0', '-0-'], '', $column->getElementId(0));
356357
if ($this->form instanceof ActiveForm && $model instanceof Model) {
357358
$field = $this->form->field($model, $column->name);
358359
foreach ($column->attributeOptions as $name => $value) {
@@ -362,12 +363,14 @@ protected function prepareJsAttributes()
362363
}
363364
$field->render('');
364365
$attributeOptions = array_pop($this->form->attributes);
365-
$attributeOptions = ArrayHelper::merge($attributeOptions, $column->attributeOptions);
366+
if (isset($attributeOptions['name']) && $attributeOptions['name'] === $column->name) {
367+
$attributes[$inputID] = ArrayHelper::merge($attributeOptions, $column->attributeOptions);
368+
} else {
369+
array_push($this->form->attributes, $attributeOptions);
370+
}
366371
} else {
367-
$attributeOptions = $column->attributeOptions;
372+
$attributes[$inputID] = $column->attributeOptions;
368373
}
369-
$inputID = str_replace(['-0', '-0-'], '', $column->getElementId(0));
370-
$attributes[$inputID] = $attributeOptions;
371374
}
372375

373376
return $attributes;

0 commit comments

Comments
 (0)