When first accessing a page, I don't always see the proper content. Upon refresh, the page loads properly.
In the initial incorrect load, it displays a breadcrumb navigation to the page it came from (Home/Projects), along with a title (Projects) and a button (Creating a New Project). The correct content is the name of the 'Pattern : Project'. The page also loads the correct table and a save button as expected; upon changing an entry in the table and saving, it behaves as expected, even if the info above the table is incorrect. This same behavior occurs for another page, with the same incorrect header info (breadcrumb, Project, Project button), but the table below is not correct.
I'm using Yii2 2.0.47 with php 8.1.13. I've done full updates via Composer.
Here is my view file:
<?php
use app\models\UserPatternProgress;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\widgets\Pjax;
use yii\grid\GridView;
?>
<h1><?= Html::encode($patternName.': '.$projectName) ?></h1>
<div class="user-param-index">
<?php Pjax::begin(); ?>
<?php $form = ActiveForm::begin([
'id' => 'user_param-form',
]); ?>
<?php
$gridColumns = [
['class' => 'yii\grid\SerialColumn'],
[
'attribute'=>'id',
'visible' => 0,
],
[
'attribute'=>'param_id',
'header'=>'Options',
'value'=> function($model){
$paramModel = new app\models\PatternParam();
$inputType = $paramModel->getParamInputType($model->param_id);
switch ($inputType) {
case 1:
return $paramModel->getParamSub2Name($model->param_id);
break;
case 2:
$progress=FALSE;
$name = $paramModel->getParamSub1Name($model->param_id);
if ($name==='SIZE') {
$userPatProgrModel = new UserPatternProgress();
$progress = $userPatProgrModel->getUserProgressDoneCtByProject($model->project_id)>0;
if($progress) {$name.=' - Any change in the selected value may lead to loss of progress!';}
}
return $name;
break;
}
},
],
[
'attribute' => 'param_value',
'header'=>'Personalize it!',
'format' => 'raw',
'value' => function ($model) {
$patParam = new app\models\PatternParam();
$inputType = $patParam->getParamInputType($model->param_id);
$name = 'UserParam['.$model->id.'][param_value]';
switch ($inputType) {
case 1:
return Html::textInput($name,\yii\helpers\Html::encode($model->param_value),['class' => 'form-control']);
break;
case 2:
$selection = \yii\helpers\Html::encode($model->param_value);
$model2 = new \app\models\PatternParam();
$keyItems = $model2->getParamsAsArray($model->param_id);
$options = ['class' => 'form-multiselect'];
return Html::dropDownList($name, $selection, $keyItems, $options);
break;
}
},
],
];
?>
<?php
Yii::$app->session->getFlash('error');
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
]);
?>
<p>
<?= Html::submitButton('Save', ['class' => 'btn btn-primary']) ?>
</p>
<?php ActiveForm::end(); ?>
<?php Pjax::end(); ?>
</div>
I searched though this site for posts on this topic, but don't see any.
Edited to add correct and incorrect images:
Incorrect image with Projects label and button
Try setting an id in Pjax on both pages and try again
\yii\widgets\Pjax::begin([
'id' => 'homepage'
]);
...
\yii\widgets\Pjax::begin([
'id' => 'grid-page'
]);