Skip to content

Commit dcb74d5

Browse files
committed
#58 how to use widget with ajax load
1 parent f1f0c73 commit dcb74d5

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ In this case you can use `enableGuessTitle` option like in the example below:
357357

358358
```
359359

360+
### Ajax load of a widget
361+
362+
Assume you want to load a widget via ajax and then show it inside modal window. In this case you MUST:
363+
364+
- Ensure that you specified ID of widget otherwise the widget will get random ID and it can be the same as id of others elements on the page.
365+
- Ensure that you use the widget inside ActiveForm because it works incorrectly in this case.
366+
367+
You can fina an example of usage in a discussion of issue #58
368+
360369
## JavaScript events
361370
This widget has following events:
362371
- `afterInit`: triggered after initialization

src/MultipleInput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ protected function initData()
129129
*/
130130
protected function guessColumns()
131131
{
132-
if (empty($this->columns) && $this->hasModel()) {
132+
if (empty($this->columns)) {
133133
$column = [
134-
'name' => $this->attribute,
134+
'name' => $this->hasModel() ? $this->attribute : $this->name,
135135
'type' => MultipleInputColumn::TYPE_TEXT_INPUT
136136
];
137137

src/components/BaseColumn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function renderInput($name, $options)
234234
$optionsExt = $this->options;
235235
}
236236

237-
$options = Arrayhelper::merge($optionsExt, $options);
237+
$options = ArrayHelper::merge($optionsExt, $options);
238238
$method = 'render' . Inflector::camelize($this->type);
239239
$value = $this->prepareValue();
240240

src/renderers/TableRenderer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ private function renderRowContent($index = null, $item = null)
141141
{
142142
$cells = [];
143143
$hiddenInputs = [];
144+
144145
foreach ($this->columns as $column) {
145146
/* @var $column BaseColumn */
146147
$column->setModel($item);

0 commit comments

Comments
 (0)