File tree Expand file tree Collapse file tree 2 files changed +8
-21
lines changed
Expand file tree Collapse file tree 2 files changed +8
-21
lines changed Original file line number Diff line number Diff line change @@ -222,15 +222,17 @@ class MultipleInput extends InputWidget
222222 */
223223 public function init ()
224224 {
225+ if (count ($ this ->columns ) === 0 ) {
226+ throw new InvalidConfigException ('You must specify at least one column ' );
227+ }
228+
225229 if ($ this ->form !== null && !$ this ->form instanceof ActiveForm) {
226230 throw new InvalidConfigException ('Property "form" must be an instance of yii\widgets\ActiveForm ' );
227231 }
228232
229233 if ($ this ->showGeneralError && $ this ->field === null ) {
230234 $ this ->showGeneralError = false ;
231235 }
232-
233- $ this ->guessColumns ();
234236 $ this ->initData ();
235237
236238 parent ::init ();
@@ -269,25 +271,6 @@ protected function initData()
269271 }
270272 }
271273
272- /**
273- * This function tries to guess the columns to show from the given data
274- * if [[columns]] are not explicitly specified.
275- */
276- protected function guessColumns ()
277- {
278- if (empty ($ this ->columns )) {
279- $ column = [
280- 'name ' => $ this ->hasModel () ? $ this ->attribute : $ this ->name ,
281- 'type ' => MultipleInputColumn::TYPE_TEXT_INPUT
282- ];
283-
284- if ($ this ->enableGuessTitle && $ this ->hasModel ()) {
285- $ column ['title ' ] = $ this ->model ->getAttributeLabel ($ this ->attribute );
286- }
287- $ this ->columns [] = $ column ;
288- }
289- }
290-
291274 /**
292275 * Run widget.
293276 */
Original file line number Diff line number Diff line change @@ -211,6 +211,10 @@ class TabularInput extends Widget
211211 */
212212 public function init ()
213213 {
214+ if (count ($ this ->columns ) === 0 ) {
215+ throw new InvalidConfigException ('You must specify at least one column ' );
216+ }
217+
214218 if (empty ($ this ->models ) && !$ this ->modelClass ) {
215219 throw new InvalidConfigException ('You must at least specify "models" or "modelClass" ' );
216220 }
You can’t perform that action at this time.
0 commit comments