Skip to content

Commit 5df7f34

Browse files
committed
Fixed initialization of element IDs
1 parent fee3e6a commit 5df7f34

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Widget.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ public function init()
9393
{
9494
parent::init();
9595

96-
if (isset($this->options['id'])) {
97-
$this->setId($this->options['id']);
96+
if (!isset($this->options['id'])) {
97+
$this->options['id'] = $this->id;
9898
}
9999
$this->registerTranslations();
100100
$this->initDefaultElements();
@@ -158,7 +158,7 @@ protected function initDefaultElements()
158158
$this->elements['bulk-actions'] = Html::dropDownList('bulkactions', null, $this->bulkActionsItems,
159159
ArrayHelper::merge([
160160
'prompt' => $this->bulkActionsPrompt,
161-
'id' => 'bulk-actions',
161+
'id' => $this->_bulkActionsId,
162162
'disabled' => $this->grid === null,
163163
], $this->bulkActionsOptions)
164164
);
@@ -177,7 +177,7 @@ protected function initDefaultElements()
177177
*/
178178
public function run()
179179
{
180-
echo Html::beginTag('div', ArrayHelper::merge(['id' => $this->id], $this->options)) . "\n";
180+
echo Html::beginTag('div', $this->options) . "\n";
181181
echo $this->renderContainer ? Html::beginTag('div', $this->containerOptions) . "\n" : '';
182182
foreach ($this->templates as $template => $options) {
183183
if (!is_array($options)) {
@@ -208,7 +208,8 @@ protected function renderElements($template)
208208
$name = $matches[1];
209209
if (isset($this->elements[$name])) {
210210
if ($name === 'bulk-actions' && $this->grid !== null) {
211-
$this->view->registerJs("$('#{$this->id} #{$this->_bulkActionsId}').change(function() {
211+
$id = $this->options['id'];
212+
$this->view->registerJs("$('#{$id} #{$this->_bulkActionsId}').change(function() {
212213
if (this.value) {
213214
var ids = $('#{$this->grid}').yiiGridView('getSelectedRows'),
214215
dataConfirm = this.options[this.selectedIndex].getAttribute('data-confirm'),

0 commit comments

Comments
 (0)