/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = TransactionTypes::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', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
<div class="transactions-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'trans_code')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'trans_date')->textInput(); ?> <?php echo $form->field($model, 'type_id')->dropDownList(ArrayHelper::map(TransactionTypes::find()->all(), 'id', 'name'), ['prompt' => '* Pilih Jenis Transaksis *']); ?> <?php echo $form->field($model, 'remarks')->textInput(['maxlength' => true]); ?> <div class="form-group"> <div class="col-xs-12 col-sm-12 col-md-12"> <h3><i class="fa fa-tasks"></i> <strong>Transactions Details</strong> </h3> </div> <div id="details"> <div data-bind="template: {name:'listTemplate', foreach:details}"></div>
/** * @return \yii\db\ActiveQuery */ public function getType() { return $this->hasOne(TransactionTypes::className(), ['id' => 'type_id']); }
/** * Finds the TransactionTypes model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return TransactionTypes the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = TransactionTypes::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }