2017-01-06 5 views
0

私は自分のレポートのカスタムモデルを作成しました。私は2つの変数fy_yrとfy_qtr.Inを宣言しました。レポートフォームには2つのコンボボックスがあり、私のコンボボックスの値に従って報告してください。しかし、私の問題は、コンボの選択値が私のカスタムモデルに設定されていないことです。問題は何ですか? マイレポートビューコード:コンボボックスの選択時に値が設定されていないYii2

<?php $form = ActiveForm::begin(['id' => 'member-report', 
    'action' => ['member-report'], 
    'method' => 'post', 
]); ?> 
<table border="1" class="table-bordered"> 

    <tr> 
     <td style="margin-right:20px;"> 

      <?= $form->field($model, 'fy_yr')->dropDownList(
      ArrayHelper::map(FiscalYear::getAllFiscalYr(),'fy_id','fiscal_yr'), 
      ['prompt'=>'Select Fiscal Year.'] 
     ) 
     ?> 
     </td> 

     <td> 

      <?= $form->field($model, 'fy_qtr')->dropDownList(
      ArrayHelper::map(CodeValue::getFiscalYrQuater(),'cv_id','cv_lbl'), 
      ['prompt'=>'Select Quarter.'] 
     ) 
     ?> 
     </td> 

    <td><input type="submit" value="Search" class="btn btn-primary btn-block btn-flat"/></td> 
    <td><input type="submit" value="Print" class="btn btn-primary btn-block btn-flatb"/></td>  
    </tr> 

</table> 
<?php ActiveForm::end(); ?> 

私のモデルは次のとおりです。

class SfclReport extends Model 
    { 
    public $fy_yr; 
    public $fy_qtr; 

    public function rules() 
    { 
     return [ 
      [['fy_id', 'fy_qtr'], 'required'], 

     ]; 
    } 


} 

と私のコントローラは

public function actionMemberReport() 
{ 

     $model = new SfclReport; 

     if ($model->load(Yii::$app->request->post())) { 


    } 
    return $this->render('member_report',['model'=>$model]); 
} 
+0

を指定します$ model-> loadを使っています(Yi –

+0

はfy_yr、fy_qtrはテーブルの列にありません –

+0

はいfy_yr、fy_qtrは次のようになります。テーブルフィールドではない –

答えて

1

fy_yrを追加し、あなたのようあなたの変数のデータ型

class SfclReport extends Model 
    { 
    public $fy_yr; 
    public $fy_qtr; 

    public function rules() 
    { 
     return [ 
      [['fy_id', 'fy_qtr'], 'required'], 
      [['fy_id',], 'integer'], 
      [['fy_yr','fy_qtr'], 'string'], 

     ]; 
    } 


} 
関連する問題