Skip to content

Commit 918f6cf

Browse files
author
Eugene Tupikov
committed
#175 simplify
1 parent 2510db7 commit 918f6cf

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Yii2 multiple input change log
66
- #215 collect all js script that has to be evaluate when add new row (not only from " on ready" section)
77
- #198 introduce the option `theme` to disable all bootstrap css classes
88
- #197 explicitly set tabindex for all inputs
9-
- #175 option `generalErrorPosition` to enable displaying of general error message
9+
- #175 option `showGeneralError` to enable displaying of general error message
1010

1111
2.16.0
1212
======

examples/views/multiple-input.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
'max' => 4,
5454
'sortable' => true,
5555
'allowEmptyList' => true,
56-
'generalErrorPosition' => 'top',
56+
'showGeneralError' => true,
5757
'rowOptions' => function($model) {
5858
$options = [];
5959

src/MultipleInput.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ class MultipleInput extends InputWidget
3737

3838
const ICONS_SOURCE_GLYPHICONS = 'glyphicons';
3939
const ICONS_SOURCE_FONTAWESOME = 'fa';
40-
41-
const GENERAL_ERROR_POS_TOP = 'top';
42-
const GENERAL_ERROR_POS_BOTTOM = 'bottom';
4340

4441
/**
4542
* @var ActiveRecordInterface[]|array[] input data
@@ -208,16 +205,10 @@ class MultipleInput extends InputWidget
208205
*/
209206
public $theme = self::THEME_BS;
210207

211-
/**
212-
* @var string|null set a position of generic error message (when you set an error for generic field instead of particular input)
213-
* If set to null no generic error message will be shown.
214-
*/
215-
public $generalErrorPosition;
216-
217208
/**
218209
* @var bool
219210
*/
220-
private $showGeneralError = false;
211+
public $showGeneralError = false;
221212

222213
/**
223214
* Initialization.
@@ -230,14 +221,8 @@ public function init()
230221
throw new InvalidConfigException('Property "form" must be an instance of yii\widgets\ActiveForm');
231222
}
232223

233-
$this->showGeneralError = $this->generalErrorPosition !== null && !$this->isEmbedded && $this->field;
234-
235-
if ($this->showGeneralError) {
236-
if ($this->generalErrorPosition === self::GENERAL_ERROR_POS_BOTTOM) {
237-
$this->field->template = "{input}\n{error}";
238-
} else {
239-
$this->field->template = "{error}\n{input}";
240-
}
224+
if ($this->showGeneralError && $this->field === null) {
225+
$this->showGeneralError = false;
241226
}
242227

243228
$this->guessColumns();

0 commit comments

Comments
 (0)