@@ -174,7 +174,7 @@ private function renderRowContent($index = null, $item = null)
174
174
$ hiddenInputs = [];
175
175
$ isLastRow = $ this ->max === $ this ->min ;
176
176
if (!$ isLastRow && $ this ->isAddButtonPositionRowBegin ()) {
177
- $ cells [] = $ this ->renderActionColumn ($ index );
177
+ $ cells [] = $ this ->renderActionColumn ($ index, true );
178
178
}
179
179
180
180
foreach ($ this ->columns as $ column ) {
@@ -187,8 +187,8 @@ private function renderRowContent($index = null, $item = null)
187
187
}
188
188
}
189
189
190
- if (!$ isLastRow && ! $ this -> isAddButtonPositionRow () ) {
191
- $ cells [] = $ this ->renderActionColumn ($ index );
190
+ if (!$ isLastRow ) {
191
+ $ cells [] = $ this ->renderActionColumn ($ index, false );
192
192
}
193
193
194
194
if ($ hiddenInputs ) {
@@ -276,30 +276,44 @@ public function renderCellContent($column, $index)
276
276
* Renders the action column.
277
277
*
278
278
* @param null|int $index
279
+ * @param bool $isFirstColumn
279
280
* @return string
280
- * @throws \Exception
281
281
*/
282
- private function renderActionColumn ($ index = null )
282
+ private function renderActionColumn ($ index = null , $ isFirstColumn = false )
283
283
{
284
- return Html::tag ('td ' , $ this ->getActionButton ($ index ), [
284
+ return Html::tag ('td ' , $ this ->getActionButton ($ index, $ isFirstColumn ), [
285
285
'class ' => 'list-cell__button ' ,
286
286
]);
287
287
}
288
288
289
- private function getActionButton ($ index )
289
+ private function getActionButton ($ index, $ isFirstColumn )
290
290
{
291
291
if ($ index === null || $ this ->min === 0 ) {
292
- return $ this ->renderRemoveButton ();
292
+ if ($ isFirstColumn ) {
293
+ return $ this ->isAddButtonPositionRowBegin () ? $ this ->renderRemoveButton () : '' ;
294
+ }
295
+
296
+ return $ this ->isAddButtonPositionRowBegin () ? '' : $ this ->renderRemoveButton ();
293
297
}
294
298
295
299
$ index ++;
296
300
if ($ index < $ this ->min ) {
297
301
return '' ;
298
- } elseif ($ index === $ this ->min ) {
299
- return ($ this ->isAddButtonPositionRow () || $ this ->isAddButtonPositionRowBegin ()) ? $ this ->renderAddButton () : '' ;
300
- } else {
301
- return $ this ->renderRemoveButton ();
302
302
}
303
+
304
+ if ($ index === $ this ->min ) {
305
+ if ($ isFirstColumn ) {
306
+ return $ this ->isAddButtonPositionRowBegin () ? $ this ->renderAddButton () : '' ;
307
+ }
308
+
309
+ return $ this ->isAddButtonPositionRow () ? $ this ->renderAddButton () : '' ;
310
+ }
311
+
312
+ if ($ isFirstColumn ) {
313
+ return $ this ->isAddButtonPositionRowBegin () ? $ this ->renderRemoveButton () : '' ;
314
+ }
315
+
316
+ return $ this ->isAddButtonPositionRowBegin () ? '' : $ this ->renderRemoveButton ();
303
317
}
304
318
305
319
private function renderAddButton ()
0 commit comments