yii2-multiple-input


(Jahau) #1

Hi,

The documentation on yii2-multiple-input widget seems to be quite limited.

I’ve got currently workproduct that has materials, which is introduced in its own model class. The following code works, but…

  1. How do I change the widget title (currently it uses the materials somehow automatically)?

  2. How do I handle the data in the controller and save it finally to the materials model? I didn’t find any examples.


        <?= $form->field($model, 'materials')->widget(MultipleInput::className(), [

            'max' => 100,

            'columns' => [

                [

                    'name'  => 'materialid',

                    'type'  => 'dropDownList',

                    'title' => $material->attributeLabels()['materialid'],

                    'defaultValue' => 0,

                    'items' => $model->activeMaterialsWithIDs

                ],

                [

                    'name'  => 'materialamount',

                    'title' => $material->attributeLabels()['materialamount'],

                    'enableError' => true,

                    'options' => [

                        'type' => 'number'

                    ]

                ]

            ]

        ]);

Thanks!