Skip to content

Commit

Permalink
fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
relbraun committed Dec 19, 2016
1 parent eaa314c commit 31b414b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,16 @@ public function actions()
];
}
```
And this is an example of the repeater_view_file.php reminded above:
```
<div class="repeater-content">
<div class="form-group">
<?= Html::label('Some label', Html::getInputId($model, "[$k]attribute")) ?>
<?= Html::activeTextInput($model, "[$k]attribute", ['class' => 'form-control']) ?>
</div>
<div class="form-group">
<?= Html::label('Other label', Html::getInputId($model, "[$k]other_attribute")) ?>
<?= Html::activeTextInput($model, "[$k]other_attribute", ['class' => 'form-control']) ?>
</div>
</div>
```
2 changes: 1 addition & 1 deletion actions/AppendAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public function run()
$id = \Yii::$app->request->post('id');
$model = new $this->model();
// $model = $model::findOne($id);
return $this->controller->renderPartial('repeater', ['model' => $model, 'contentPath' => $this->contentPath]);
return $this->controller->renderPartial('repeater', ['model' => $model, 'contentPath' => $this->contentPath, 'k' => $id]);
}
}
2 changes: 1 addition & 1 deletion actions/DeleteAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DeleteAction extends Action
public function run()
{
$id = \Yii::$app->request->post('id');
$model = $this->model;
$model = $this->model;
/** @var ActiveRecord $model */
$model = $model::findOne($id);
$response = 0;
Expand Down
1 change: 1 addition & 0 deletions js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jQuery(function($){
var data ={id:self.id};
data[yii.getCsrfParam()]=yii.getCsrfToken();
data.additionalData = $('.repeater-item').find('input,select,textarea').serialize();
data.id = self.id;
$.post(appendUrl,data, function(data){
$wrap.append($(data));
});
Expand Down
2 changes: 1 addition & 1 deletion views/repeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="repeater-item" data-id="<?= $model->primaryKey ?>">
<?php if(isset($contentPath)){
$content = $this->render($contentPath, ['model' => $model]);
$content = $this->render($contentPath, ['model' => $model, 'k' => $k]);
} ?>
<?= $content ?>
<a class="remove" href="javascript:;" >X</a>
Expand Down

0 comments on commit 31b414b

Please sign in to comment.