44use unclead \widgets \MultipleInput ;
55use unclead \widgets \examples \models \ExampleModel ;
66use yii \helpers \Html ;
7+ use nex \chosen \Chosen ;
8+ use unclead \widgets \MultipleInputColumn ;
79
810// Note: You have to install https://github.com/kartik-v/yii2-widget-datepicker for correct work an example
911use kartik \date \DatePicker ;
1012
11- /* @var $this \yii\base \View */
13+ /* @var $this \yii\web \View */
1214/* @var $model ExampleModel */
1315?>
1416
1517<?php $ form = ActiveForm::begin ([
1618 'enableAjaxValidation ' => true ,
19+ // 'enableAjaxValidation' => false,
1720 'enableClientValidation ' => false ,
1821 'validateOnChange ' => false ,
1922 'validateOnSubmit ' => true ,
2023 'validateOnBlur ' => false ,
2124]);?>
2225
23- <h3>Single column</h3>
26+ <h3>Single column</h3>
2427<?php
25- echo $ form ->field ($ model , 'emails ' )->widget (MultipleInput::className (), [
26- 'limit ' => 5
27- ])
28- ->label (false );
28+ // echo $form->field($model, 'emails')->widget(MultipleInput::className(), [
29+ // 'limit' => 5
30+ // ])
31+ // ->label(false);
2932?>
3033
31- <h3>Multiple columns</h3>
34+ <h3>Multiple columns</h3>
3235<?= $ form ->field ($ model , 'schedule ' )->widget (MultipleInput::className (), [
36+ 'id ' => 'schedule-wrapper ' ,
3337 'limit ' => 4 ,
3438 'columns ' => [
3539 [
3640 'name ' => 'user_id ' ,
37- 'type ' => 'dropDownList ' ,
41+ 'type ' => MultipleInputColumn::TYPE_DROPDOWN ,
42+ 'enableError ' => true ,
3843 'title ' => 'User ' ,
39- 'defaultValue ' => 1 ,
44+ 'defaultValue ' => 33 ,
4045 'items ' => [
41- 1 => 'User 1 ' ,
42- 2 => 'User 2 '
43- ]
46+ '' => 'Select user ' ,
47+ 31 => 'item 31 ' ,
48+ 32 => 'item 32 ' ,
49+ 33 => 'item 33 ' ,
50+ 34 => 'item 34 ' ,
51+ 35 => 'item 35 ' ,
52+ 36 => 'item 36 ' ,
53+ ],
4454 ],
4555 [
4656 'name ' => 'day ' ,
6777 [
6878 'name ' => 'priority ' ,
6979 'title ' => 'Priority ' ,
80+ 'defaultValue ' => 1 ,
81+ 'enableError ' => true ,
7082 'options ' => [
7183 'class ' => 'input-priority '
7284 ]
8092 'headerOptions ' => [
8193 'style ' => 'width: 70px; ' ,
8294 ]
95+ ],
96+ [
97+ 'type ' => 'checkbox ' ,
98+ 'name ' => 'enable ' ,
99+ 'defaultValue ' => 0
83100 ]
84101 ]
85- ]);
102+ ]);
86103?>
87104<?= Html::submitButton ('Update ' , ['class ' => 'btn btn-success ' ]);?>
88- <?php ActiveForm::end ();?>
105+ <?php ActiveForm::end ();?>
106+
107+
108+ <?php
109+ $ js = <<< JS
110+ $('#schedule-wrapper').on('afterInit', function(){
111+ console.log('calls on after initialization event');
112+ }).on('beforeAddRow', function(e) {
113+ console.log('calls on before add row event');
114+ }).on('afterAddRow', function(e) {
115+ console.log('calls on after add row event');
116+ }).on('beforeDeleteRow', function(){
117+ console.log('calls on before remove row event');
118+ return confirm('Are you sure you want to delete row?')
119+ }).on('afterDeleteRow', function(){
120+ console.log('calls on after remove row event');
121+ });
122+ JS ;
123+
124+ $ this ->registerJs ($ js );
0 commit comments