@@ -130,7 +130,7 @@ public function init()
130
130
131
131
private function prepareColumnClass ()
132
132
{
133
- if (empty ( $ this ->columnClass ) ) {
133
+ if (! $ this ->columnClass ) {
134
134
throw new InvalidConfigException ('You must specify "columnClass" ' );
135
135
}
136
136
@@ -142,15 +142,15 @@ private function prepareColumnClass()
142
142
private function prepareMinOption ()
143
143
{
144
144
// Set value of min option based on value of allowEmptyList for BC
145
- if (is_null ( $ this ->min ) ) {
145
+ if ($ this ->min === null ) {
146
146
$ this ->min = $ this ->allowEmptyList ? 0 : 1 ;
147
147
} else {
148
148
if ($ this ->min < 0 ) {
149
149
throw new InvalidConfigException ('Option "min" cannot be less 0 ' );
150
150
}
151
151
152
152
// Allow empty list in case when minimum number of rows equal 0.
153
- if ($ this ->min == 0 && !$ this ->allowEmptyList ) {
153
+ if ($ this ->min === 0 && !$ this ->allowEmptyList ) {
154
154
$ this ->allowEmptyList = true ;
155
155
}
156
156
@@ -163,7 +163,7 @@ private function prepareMinOption()
163
163
164
164
private function prepareLimit ()
165
165
{
166
- if (is_null ( $ this ->limit ) ) {
166
+ if ($ this ->limit === null ) {
167
167
$ this ->limit = 999 ;
168
168
}
169
169
@@ -172,33 +172,35 @@ private function prepareLimit()
172
172
}
173
173
174
174
// Maximum number of rows cannot be less then minimum number.
175
- if (! is_null ( $ this ->limit ) && $ this ->limit < $ this ->min ) {
175
+ if ($ this ->limit !== null && $ this ->limit < $ this ->min ) {
176
176
$ this ->limit = $ this ->min ;
177
177
}
178
178
}
179
179
180
180
private function prepareButtonsOptions ()
181
181
{
182
- if (!isset ( $ this ->removeButtonOptions [ ' class ' ] )) {
182
+ if (!array_key_exists ( ' class ' , $ this ->removeButtonOptions )) {
183
183
$ this ->removeButtonOptions ['class ' ] = 'btn btn-danger ' ;
184
184
}
185
185
186
- if (!isset ( $ this ->removeButtonOptions [ ' label ' ] )) {
186
+ if (!array_key_exists ( ' label ' , $ this ->removeButtonOptions )) {
187
187
$ this ->removeButtonOptions ['label ' ] = Html::tag ('i ' , null , ['class ' => 'glyphicon glyphicon-remove ' ]);
188
188
}
189
189
190
- if (!isset ( $ this ->addButtonOptions [ ' class ' ] )) {
190
+ if (!array_key_exists ( ' class ' , $ this ->addButtonOptions )) {
191
191
$ this ->addButtonOptions ['class ' ] = 'btn btn-default ' ;
192
192
}
193
193
194
- if (!isset ( $ this ->addButtonOptions [ ' label ' ] )) {
194
+ if (!array_key_exists ( ' label ' , $ this ->addButtonOptions )) {
195
195
$ this ->addButtonOptions ['label ' ] = Html::tag ('i ' , null , ['class ' => 'glyphicon glyphicon-plus ' ]);
196
196
}
197
197
}
198
198
199
199
200
200
/**
201
201
* Creates column objects and initializes them.
202
+ *
203
+ * @throws \yii\base\InvalidConfigException
202
204
*/
203
205
protected function initColumns ()
204
206
{
@@ -211,8 +213,8 @@ protected function initColumns()
211
213
if ($ this ->context instanceof MultipleInput) {
212
214
$ definition ['widget ' ] = $ this ->context ;
213
215
}
214
- $ column = Yii:: createObject ( $ definition );
215
- $ this ->columns [$ i ] = $ column ;
216
+
217
+ $ this ->columns [$ i ] = Yii:: createObject ( $ definition ) ;
216
218
}
217
219
}
218
220
@@ -233,6 +235,7 @@ abstract protected function internalRender();
233
235
/**
234
236
* Register script.
235
237
*
238
+ * @throws \yii\base\InvalidParamException
236
239
*/
237
240
protected function registerClientScript ()
238
241
{
@@ -243,16 +246,14 @@ protected function registerClientScript()
243
246
$ template = $ this ->prepareTemplate ();
244
247
$ jsTemplates = $ this ->collectJsTemplates ($ jsBefore );
245
248
246
- $ options = Json::encode (
247
- [
248
- 'id ' => $ this ->id ,
249
- 'template ' => $ template ,
250
- 'jsTemplates ' => $ jsTemplates ,
251
- 'limit ' => $ this ->limit ,
252
- 'min ' => $ this ->min ,
253
- 'attributeOptions ' => $ this ->attributeOptions ,
254
- ]
255
- );
249
+ $ options = Json::encode ([
250
+ 'id ' => $ this ->id ,
251
+ 'template ' => $ template ,
252
+ 'jsTemplates ' => $ jsTemplates ,
253
+ 'limit ' => $ this ->limit ,
254
+ 'min ' => $ this ->min ,
255
+ 'attributeOptions ' => $ this ->attributeOptions ,
256
+ ]);
256
257
257
258
$ js = "jQuery('# {$ this ->id }').multipleInput( $ options); " ;
258
259
$ view ->registerJs ($ js );
0 commit comments