@@ -117,14 +117,14 @@ private function hasHeader()
117
117
if ($ this ->min === 0 || $ this ->isAddButtonPositionHeader ()) {
118
118
return true ;
119
119
}
120
-
120
+
121
121
foreach ($ this ->columns as $ column ) {
122
122
/* @var $column BaseColumn */
123
123
if ($ column ->title ) {
124
124
return true ;
125
125
}
126
126
}
127
-
127
+
128
128
return false ;
129
129
}
130
130
@@ -141,7 +141,7 @@ private function renderHeaderCell($column)
141
141
142
142
$ options = $ column ->headerOptions ;
143
143
Html::addCssClass ($ options , 'list-cell__ ' . $ column ->name );
144
-
144
+
145
145
return Html::tag ('th ' , $ column ->title , $ options );
146
146
}
147
147
@@ -186,7 +186,7 @@ protected function renderBody()
186
186
$ rows [] = $ this ->renderRowContent ($ i );
187
187
}
188
188
}
189
-
189
+
190
190
return Html::tag ('tbody ' , implode ("\n" , $ rows ));
191
191
}
192
192
@@ -207,13 +207,14 @@ private function renderRowContent($index = null, $item = null)
207
207
$ cells [] = $ this ->renderActionColumn ($ index , $ item , true );
208
208
}
209
209
210
+ $ columnIndex = 0 ;
210
211
foreach ($ this ->columns as $ column ) {
211
212
/* @var $column BaseColumn */
212
213
$ column ->setModel ($ item );
213
214
if ($ column ->isHiddenInput ()) {
214
- $ hiddenInputs [] = $ this ->renderCellContent ($ column , $ index );
215
+ $ hiddenInputs [] = $ this ->renderCellContent ($ column , $ index, $ columnIndex ++ );
215
216
} else {
216
- $ cells [] = $ this ->renderCellContent ($ column , $ index );
217
+ $ cells [] = $ this ->renderCellContent ($ column , $ index, $ columnIndex ++ );
217
218
}
218
219
}
219
220
if ($ this ->cloneButton ) {
@@ -228,7 +229,7 @@ private function renderRowContent($index = null, $item = null)
228
229
$ hiddenInputs = implode ("\n" , $ hiddenInputs );
229
230
$ cells [0 ] = preg_replace ('/^(<td[^>]+>)(.*)(<\/td>)$/s ' , '${1} ' . $ hiddenInputs . '$2$3 ' , $ cells [0 ]);
230
231
}
231
-
232
+
232
233
$ content = Html::tag ('tr ' , implode ("\n" , $ cells ), $ this ->prepareRowOptions ($ index , $ item ));
233
234
234
235
if ($ index !== null ) {
@@ -263,9 +264,10 @@ protected function prepareRowOptions($index, $item)
263
264
*
264
265
* @param BaseColumn $column
265
266
* @param int|null $index
267
+ * @param int|null $columnIndex
266
268
* @return string
267
269
*/
268
- public function renderCellContent ($ column , $ index )
270
+ public function renderCellContent ($ column , $ index, $ columnIndex = null )
269
271
{
270
272
$ id = $ column ->getElementId ($ index );
271
273
$ name = $ column ->getElementName ($ index );
@@ -279,7 +281,14 @@ public function renderCellContent($column, $index)
279
281
if (substr ($ id , -4 ) === 'drag ' ) {
280
282
$ options = ArrayHelper::merge ($ options , ['class ' => $ this ->iconMap ['drag-handle ' ]]);
281
283
}
282
- $ input = $ column ->renderInput ($ name , $ options );
284
+ $ input = $ column ->renderInput ($ name , $ options , [
285
+ 'id ' => $ id ,
286
+ 'name ' => $ name ,
287
+ 'indexPlaceholder ' => $ this ->getIndexPlaceholder (),
288
+ 'index ' => $ index ,
289
+ 'columnIndex ' => $ columnIndex ,
290
+ 'context ' => $ this ->context ,
291
+ ]);
283
292
284
293
if ($ column ->isHiddenInput ()) {
285
294
return $ input ;
@@ -305,15 +314,15 @@ public function renderCellContent($column, $index)
305
314
if ($ hasError ) {
306
315
Html::addCssClass ($ wrapperOptions , 'has-error ' );
307
316
}
308
-
317
+
309
318
if (is_callable ($ column ->columnOptions )) {
310
319
$ columnOptions = call_user_func ($ column ->columnOptions , $ column ->getModel (), $ index , $ this ->context );
311
320
} else {
312
321
$ columnOptions = $ column ->columnOptions ;
313
322
}
314
323
315
324
Html::addCssClass ($ columnOptions , 'list-cell__ ' . $ column ->name );
316
-
325
+
317
326
$ input = Html::tag ('div ' , $ input , $ wrapperOptions );
318
327
319
328
return Html::tag ('td ' , $ input , $ columnOptions );
@@ -386,7 +395,7 @@ private function renderAddButton()
386
395
];
387
396
388
397
Html::addCssClass ($ options , $ this ->addButtonOptions ['class ' ]);
389
-
398
+
390
399
return Html::tag ('div ' , $ this ->addButtonOptions ['label ' ], $ options );
391
400
}
392
401
@@ -402,7 +411,7 @@ private function renderRemoveButton()
402
411
];
403
412
404
413
Html::addCssClass ($ options , $ this ->removeButtonOptions ['class ' ]);
405
-
414
+
406
415
return Html::tag ('div ' , $ this ->removeButtonOptions ['label ' ], $ options );
407
416
}
408
417
0 commit comments