/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Companys::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'company_name', $this->company_name])->andFilterWhere(['like', 'address', $this->address]); return $dataProvider; }
<div class="row"> <div class="col-xs-6 col-sm-6 col-md-6"> <?php echo $form->field($model, 'budget')->radioList(app\models\Tools::itemAlias('budget')); ?> </div> <div class="col-xs-6 col-sm-6 col-md-6"> <?php echo $form->field($model, 'howbuy')->radioList(app\models\Tools::itemAlias('howbuy')); ?> </div> </div> <div class="row"> <div class="col-xs-6 col-sm-6 col-md-6"> <?php echo $form->field($model, 'company_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Companys::find()->all(), 'id', 'company_name'), 'language' => 'th', 'options' => ['placeholder' => 'เลือกบริษัท ...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-xs-3 col-sm-3 col-md-3"> <?php echo $form->field($model, 'price')->textInput(['maxlength' => true]); ?> </div> </div> <div class="row"> <div class="col-xs-3 col-sm-3 col-md-3"> <?php echo $form->field($model, 'serial')->textInput(['maxlength' => true]); ?> </div>
public function getComtool() { // ความสัมพันธ์จาก tools ไปหา companys return $this->hasOne(Companys::className(), ['id' => 'company_id']); }
/** * Finds the Companys model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Companys the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Companys::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }