title: How to pass data from model to a view in yii2
body: <p>Here, I'm trying to design a payslip. I want to pass data from model right beside the text. like - </p>
  
  <pre><code>&lt;p class="text-center"&gt;Pay Slip for the month of  &lt;/p&gt;
  </code></pre>
  
  <p>The data will be fetched from the model and will be passed right beside "Pay Slip for the month of". Please help.</p>
  
  <p>My Controller Action</p>
  
  <pre><code>public function actionPrintsalarystatement($id) {
  
          //$model =  Salary::find()-&gt;where(['s_id' =&gt; $id]);
          $model = $this-&gt;findModel($id);
          $searchModel  = new SalarySearch();
          $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
          $data         = Salary::findOne($id);
          $content = $this-&gt;renderPartial('_printSalarystatement', ['model' =&gt; $model,'dataProvider' =&gt; $dataProvider,'searchModel'  =&gt; $searchModel,'data'=&gt; $data]);
          $pdf = new Pdf([
              'mode'=&gt; Pdf::MODE_UTF8,
              'format'=&gt; Pdf::FORMAT_A4,
              'destination'=&gt; Pdf::DEST_BROWSER,
              //'destination' =&gt; Pdf::DEST_DOWNLOAD,
              'cssFile' =&gt; '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
              // any css to be embedded if required
              'cssInline' =&gt; '.kv-heading-1{font-size:18px}', 
               // set mPDF properties on the fly
              'options' =&gt; ['title' =&gt; 'Print Payslip'],
               // call mPDF methods on the fly
              'methods' =&gt; [
                  'SetHeader'=&gt;['Private and Confidential'], 
                  'SetFooter'=&gt;['This Payslip is computer generated.'],
              ],
              'content'     =&gt; $content,
  
  
          ]);
          return $pdf-&gt;render();
          //return $this-&gt;render('_printSalarystatement', ['period' =&gt; 's_period']);
      }
  </code></pre>
  
  <p>_printSalarystatement.php</p>
  
  <pre><code>&lt;?php
  
  use yii\helpers\Html;
  use yii\widgets\DetailView;
  
  /* @var $this yii\web\View */
  /* @var $model frontend\modules\salary\models\Salary */
  //@var $model yii\base\Model
  //@var $totaldays any
  
  //$this-&gt;title = $model-&gt;s_id;
  $this-&gt;params['breadcrumbs'][] = ['label' =&gt; 'Salaries', 'url' =&gt; ['index']];
  $this-&gt;params['breadcrumbs'][] = $this-&gt;title;
  ?&gt;
  &lt;div class="salary-view"&gt;
  
      &lt;h1&gt;&lt;?= Html::encode($this-&gt;title) ?&gt;&lt;/h1&gt;
      &lt;h1&gt;&lt;strong&gt;&lt;p class="text-center"&gt;PS Enterprise&lt;/p&gt;&lt;/strong&gt;&lt;/h1&gt;
      &lt;p class="text-center"&gt;Pay Slip for the month of s_period &lt;/p&gt;
  
  
      &lt;?= DetailView::widget([
          'model' =&gt; $model,
          'attributes' =&gt; [
              's_id',
              's_date',
              's_period',
              's_empid',
              's_empname',
              's_workingdays',
              's_leave',
              's_holiday',
              's_wageperday',
              's_totalwage',
              's_ovthour',
              's_ovtrateperhour',
              's_ovtamount',
              's_tiffinworkingday',
              's_tiffinrateperday',
              's_wdtiffinamount',
              's_sundayworked',
              's_sundayrate',
              's_sundaytiffinamount',
              's_nightcount',
              's_nightallrate',
              's_nightallowance',
              's_convday',
              's_convrate',
              's_conveyanceamount',
              's_tiffinovtcount',
              's_tiffinovtrate',
              's_tiffinovtamount',
              's_incentivecount',
              's_incentiverate',
              's_incentive',
              's_totalearning',
              's_epf',
              's_esi',
              's_ptax',
              's_takehome',
          ],
      ]) ?&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>By the controller action I get the following screen
  <a href="https://i.stack.imgur.com/FiK7u.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FiK7u.jpg" alt="enter image description here"></a></p>
  
  <p>What I want is to pass the period that is in the detailview to be shown after the line "Pay Slip for the month of ". mY question is how to do that</p>