PHP code example of vsk / modal-form
1. Go to this page and download the library: Download vsk/modal-form library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vsk / modal-form example snippets
class TestController extends Controller
{
public function actions()
{
return [
'modal-form' => [
'class' => ModalFormAction::class,
'getBody' => function ($action) {
return $this->render('@vendor/vsk/modal-form/src/test/views/modal-list');
},
'getTitle' => function() {
return 'Список тестовых данных';
},
],
'modal-form-update' => [
'class' => ModalFormAction::class,
'getBody' => function ($action) {
return $this->render('@vendor/vsk/modal-form/src/test/views/update', [
'model' => $action->getModel(),
]);
},
'getTitle' => function() {
return 'title';
},
'getModel' => function () {
$id = \Yii::$app->request->get('id');
return Test::findOne($id);
},
'submitForm' => function ($action) {
$model = $action->getModel();
$model->load(\Yii::$app->request->post());
return $model->save();
}
],
];
}
}
echo \vsk\modalForm\ModalFormWidget::widget([
'template' => function ($widget) {
$id = $widget->getId();
return "<button id='{$id}' data-modal-url='/adminx24/test/modal-form'>TEST</button>";
}
]);