Skip to content

Commit 5c2f2d7

Browse files
committed
Added note about using placeholder in configuration of the widget
1 parent 8702032 commit 5c2f2d7

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ Use the following code for this purpose:
261261
[
262262
'name' => 'title',
263263
'title' => 'Title',
264-
'type' => \unclead\widgets\MultipleInputColumn::TYPE_TEXT_INPUT,
264+
'type' => TabularInputColumn::TYPE_TEXT_INPUT,
265265
],
266266
[
267267
'name' => 'description',
@@ -366,6 +366,51 @@ Assume you want to load a widget via ajax and then show it inside modal window.
366366

367367
You can fina an example of usage in a discussion of [issue](https://github.com/unclead/yii2-multiple-input/issues/58)
368368

369+
### Using of a placeholder {multiple_index}
370+
371+
You can use a placeholder {multiple index} in a widget configuration, e.g. for implementation of dependent drop down lists.
372+
373+
```php
374+
<?= $form->field($model, 'field')->widget(MultipleInput::className(), [
375+
'allowEmptyList' => false,
376+
'rowOptions' => [
377+
'id' => 'row{multiple_index}',
378+
],
379+
'columns' => [
380+
[
381+
'name' => 'category',
382+
'type' => 'dropDownList',
383+
'title' => 'Category',
384+
'defaultValue' => '1',
385+
'items' => [
386+
'1' => 'Test 1',
387+
'2' => 'Test 2',
388+
'3' => 'Test 3',
389+
'4' => 'Test 4',
390+
],
391+
'options' => [
392+
'onchange' => <<< JS
393+
$.post("list?id=" + $(this).val(), function(data){
394+
console.log(data);
395+
$("select#subcat-{multiple_index}").html(data);
396+
});
397+
JS
398+
],
399+
],
400+
[
401+
'name' => 'subcategory',
402+
'type' => 'dropDownList',
403+
'title' => 'Subcategory',
404+
'items' => [],
405+
'options'=> [
406+
'id' => 'subcat-{multiple_index}'
407+
],
408+
],
409+
]
410+
]);
411+
?>
412+
```
413+
369414
## JavaScript events
370415
This widget has following events:
371416
- `afterInit`: triggered after initialization

0 commit comments

Comments
 (0)