Использую модуль
demos.krajee.com/builder-details/tabular-form
самый последний.
<div class="panel-body">
<?php
$form = kartik\form\ActiveForm::begin(
[ 'id'=> $model->formName(),
]
);
echo TabularForm::widget([
// your data provider
'dataProvider' => $dataCertificate,
'form' => $form,
'staticOnly' => true,
'actionColumn' => false,
'attributes' => [
'certificate_code' => ['label' => 'certificate_code', 'type' => TabularForm::INPUT_HIDDEN_STATIC]
],
]);
?>
не пойму как сделать валидацию и сохранить модели.
public function actionIndex() {
$model = new PackagesForm();
$certificates = Certificate::find()->where(['certificates.user_id' => Yii::$app->user->identity->id]);
$packages = Packages::find();
$dataProvider = new ActiveDataProvider([
'query' => $packages,
'sort' => [
'defaultOrder' => ['id' => SORT_DESC],
],
]);
$dataCertificate = new ActiveDataProvider([
'query' => $certificates,
'sort' => [
'defaultOrder' => ['id' => SORT_DESC],
],
]);
if (\yii\base\Model::loadMultiple($model, Yii::$app->request->post(), $formName = $model->formName()) && Model::validateMultiple($model)) {
$count = 0;
foreach ($models as $index => $model) {
// populate and save records for each model
if ($model->save()) {
$count++;
}
}
return $this->render('index', [
'model' => $model,
'certificates' => $certificates,
'dataProvider' => $dataProvider,
'dataCertificate' => $dataCertificate,
]);
} else {
var_dump(\yii\base\Model::loadMultiple($model, Yii::$app->request->post(), $formName = $model->formName()));
die();
return $this->render('index', [
'model' => $model,
'certificates' => $certificates,
'dataProvider' => $dataProvider,
'dataCertificate' => $dataCertificate,
]);
}
}
\yii\base\Model::loadMultiple($model, Yii::$app->request->post(), $formName = $model->formName()) - Не проходит