I need to add a textfield which does not belong to the model. So I've added the following code in the form
<?= Html::textInput("totaldays", $value) ?>
Please tell me how to declare this variable or how can I resolve this. I've tried adding
public $value;
in the model. But the error remains. Please help.
Controller
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
'totaldays' => $value,
]);
}
view.php
<?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->title = $model->s_id;
$this->params['breadcrumbs'][] = ['label' => 'Salaries', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="salary-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a('Update', ['update', 'id' => $model->s_id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->s_id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'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',
],
]) ?>
</div>
_form.php
<div class="col-xs-4 col-sm-4 col-lg-4">
<?= Html::textInput("totaldays", $value) ?>
</div>
error -
Undefined variable: value