Skip to content

Commit 54e8d55

Browse files
committed
Respect "addButtonPosition" option when rendering the button
1 parent a202350 commit 54e8d55

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/MultipleInput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ class MultipleInput extends InputWidget
7676
public $min;
7777

7878
/**
79-
* @var string|array position of add button. By default button is rendered in the row.
79+
* @var string|array position of add button.
8080
*/
81-
public $addButtonPosition = self::POS_ROW;
81+
public $addButtonPosition;
8282

8383
/**
8484
* @var array|\Closure the HTML attributes for the table body rows. This can be either an array

src/TabularInput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ class TabularInput extends Widget
6969
public $models;
7070

7171
/**
72-
* @var string|array position of add button. By default button is rendered in the row.
72+
* @var string|array position of add button.
7373
*/
74-
public $addButtonPosition = self::POS_ROW;
74+
public $addButtonPosition;
7575

7676
/**
7777
* @var array|\Closure the HTML attributes for the table body rows. This can be either an array

src/renderers/BaseRenderer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ private function prepareLimit()
182182

183183
private function prepareButtons()
184184
{
185+
if ($this->addButtonPosition === null || $this->addButtonPosition === []) {
186+
$this->addButtonPosition = $this->min === 0 ? self::POS_HEADER : self::POS_ROW;
187+
}
185188
if (!is_array($this->addButtonPosition)) {
186189
$this->addButtonPosition = (array) $this->addButtonPosition;
187190
}

src/renderers/TableRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function renderHeader()
5959
}
6060

6161
if ($this->limit === null || ($this->limit >= 1 && $this->limit !== $this->min)) {
62-
$button = $this->min === 0 || $this->isAddButtonPositionHeader() ? $this->renderAddButton() : '';
62+
$button = $this->isAddButtonPositionHeader() ? $this->renderAddButton() : '';
6363

6464
$cells[] = Html::tag('th', $button, [
6565
'class' => 'list-cell__button'

0 commit comments

Comments
 (0)