Pass data from a form to a controller in yii2

前端 未结 1 614
逝去的感伤
逝去的感伤 2021-01-27 01:04

I am creating a page that has 3 fields - product code, startdate, enddate. When I click on the search button it should create a pdf file. 3 of these fields are without model. <

相关标签:
1条回答
  • 2021-01-27 01:37

    I'm not sure how it works without rendering... But anyway, to make them defined, you need to pass them to view file. The most common method (and I think the best by far) is to use $this->render() operation. At the end of of your public function actionStockbetweendates($upc, $startdate, $enddate) { add this:

    return $this->render('index2', [
        'upc' => $upc,
        'startdate' => $startdate,
        'enddate' => $enddate,
    ];
    

    One side note: you don't need to use these:

    $upc = yii::$app->request->get('upc');
    $startdate = yii::$app->request->get('startdate');
    $enddate = yii::$app->request->get('enddate');
    

    They are already defined (used) in parameters.

    0 讨论(0)
提交回复
热议问题