@@ -174,7 +174,7 @@ private function renderRowContent($index = null, $item = null)
174174 $ hiddenInputs = [];
175175 $ isLastRow = $ this ->max === $ this ->min ;
176176 if (!$ isLastRow && $ this ->isAddButtonPositionRowBegin ()) {
177- $ cells [] = $ this ->renderActionColumn ($ index );
177+ $ cells [] = $ this ->renderActionColumn ($ index, true );
178178 }
179179
180180 foreach ($ this ->columns as $ column ) {
@@ -187,8 +187,8 @@ private function renderRowContent($index = null, $item = null)
187187 }
188188 }
189189
190- if (!$ isLastRow && ! $ this -> isAddButtonPositionRow () ) {
191- $ cells [] = $ this ->renderActionColumn ($ index );
190+ if (!$ isLastRow ) {
191+ $ cells [] = $ this ->renderActionColumn ($ index, false );
192192 }
193193
194194 if ($ hiddenInputs ) {
@@ -276,30 +276,44 @@ public function renderCellContent($column, $index)
276276 * Renders the action column.
277277 *
278278 * @param null|int $index
279+ * @param bool $isFirstColumn
279280 * @return string
280- * @throws \Exception
281281 */
282- private function renderActionColumn ($ index = null )
282+ private function renderActionColumn ($ index = null , $ isFirstColumn = false )
283283 {
284- return Html::tag ('td ' , $ this ->getActionButton ($ index ), [
284+ return Html::tag ('td ' , $ this ->getActionButton ($ index, $ isFirstColumn ), [
285285 'class ' => 'list-cell__button ' ,
286286 ]);
287287 }
288288
289- private function getActionButton ($ index )
289+ private function getActionButton ($ index, $ isFirstColumn )
290290 {
291291 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 ();
293297 }
294298
295299 $ index ++;
296300 if ($ index < $ this ->min ) {
297301 return '' ;
298- } elseif ($ index === $ this ->min ) {
299- return ($ this ->isAddButtonPositionRow () || $ this ->isAddButtonPositionRowBegin ()) ? $ this ->renderAddButton () : '' ;
300- } else {
301- return $ this ->renderRemoveButton ();
302302 }
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 ();
303317 }
304318
305319 private function renderAddButton ()
0 commit comments