I've selected id from the button. Every time I select id to be copied to another page. Like a Cart Shoping, where you can see the selected products.
Here's what I've done
in Controller
public function actionClone($id)
{
$model = $this->findModel($id);
$newModel = new Masa();
$newModel->attributes = $model->attributes;
$newModel->save(false);
$newModel->save();
}
public function actionTabel()
{
$searchModel = new MasaSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
foreach( $model->models as $id) {
$newModel = new Masa();
$newModel->attributes = $id->attributes;
$newModel->save();
}
return $this->render('tabel',[
'models'=>$newModel,
]);
}
in view
'clone' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-floppy-open">Clonare</span>',
Yii::$app->urlManager->createUrl(['masa/clone', 'id' => $model->id]),
[
'title' => Yii::t('yii', 'Clonare'),
'url' => Url::to(["/masa/clone", 'id' => $model->id]),
]
) . "</li>";
},
I have two attributes id and name,for simplicity.