フィールドとボタン付きの検索フォームが1つあります。ボタンをクリックして、私は2 searchmodel - sellitembtdtSearch
とpuritembtdtSearch
を検索したいです。結果は1つのビューで表示されます。私は問題なくビューを表示できます。問題は、私が検索している検索モードが1つだけであることです。どのようにsametimeでsearchModelを検索することができますか教えてください。2つのモデルからの2つのモデルからの2つのモデルyii2の単一フィールドによる検索
最初に、私はindex2.phpページ上のフォームがある場所に着陸します。
'action' => ['/stock/sellitem/printproductledger3',],
'method' => 'get',
<?= $form->field($model, 'productname')->textInput(['maxlength' => true,]) ?>
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
actionIndex2.php
public function actionIndex2()
{
$searchModel1 = new SellitemsbdtSearch();
$dataProvider1 = $searchModel1->search(Yii::$app->request->queryParams);
$searchModel2 = new PuritemsbdtSearch();
$dataProvider2 = $searchModel2->search(Yii::$app->request->queryParams);
return $this->render('_formbtdt', [
'model' => $searchModel2,
//'searchModel1' => $searchModel2,
]);
}
public function actionPrintproductledger3() {
$searchModel1 = new SellitemsbdtSearch();
$dataProvider1 = $searchModel1->search(Yii::$app->request->get());
$searchModel2 = new PuritemsbdtSearch();
$dataProvider2 = $searchModel2->search(Yii::$app->request->get());
//$productname = yii::$app->request->get('productname');
//$prodesc = yii::$app->request->get('prodesc');
$content = $this->renderPartial('_printproductledgerbtdt', [
//'productname' => $productname,
'searchModel1' => $searchModel1,
'dataProvider1' => $dataProvider1,
'searchModel2' => $searchModel2,
'dataProvider2' => $dataProvider2,
//'prodesc' => $prodesc,
]);
return $this->render('_printproductledgerbtdt', [
'dataProvider1' => $dataProvider1,
'searchModel1' => $searchModel1,
'searchModel2' => $searchModel2,
'dataProvider2' => $dataProvider2,
]);
このコードはpuritemdtdtSearch
を捜します。私はpuritembtdtSearch
とsellitembtdtSearch
を同時に検索したい。ありがとう。
あなたはajaxの使用を検討しましたか?異なるsearchModelsを検索する必要があることはどういう意味ですか... 1つのsearchModelを検索し、関係があれば関係を使用することができます –
はい。ここに - http://stackoverflow.com/questions/41900399/display-pdf-in-browser-by-calling-controller-action-by-ajax-in-yii2 ... – Tanmay
彼らは共通のフィールドを持っていますが、私が望むように2つの別個のグリッドビューを表示するには、別々の検索モデルを作成したいと思います。 – Tanmay