/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ProgramHead::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, 'head_id' => $this->head_id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
public function getProgramHead() { return @$this->hasOne(ProgramHead::className(), ['id' => 'risk_program_head']); }
<div class="col-xs-6 col-sm-6"> <?php echo $form->field($model, 'risk_level')->widget(Select2::classname(), ['data' => ArrayHelper::map(RiskLevel::find()->all(), 'level', 'name'), 'options' => ['placeholder' => 'เลือกระดับความรุนแรง ...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-xs-6 col-sm-6"> <?php echo $form->field($model, 'risk_head_department')->textInput(['maxlength' => true]); ?> </div> <div class="col-sm-4 col-md-4"> <?php echo $form->field($model, 'risk_program_head')->dropdownList(ArrayHelper::map(ProgramHead::find()->all(), 'id', 'name'), ['id' => 'ddl-risk_program_head', 'prompt' => 'เลือกโปรแกรมความเสี่ยง']); ?> </div> <div class="col-sm-4 col-md-4"> <?php echo $form->field($model, 'risk_program_detail')->widget(DepDrop::classname(), ['options' => ['id' => 'ddl-risk_program_detail'], 'data' => [], 'pluginOptions' => ['depends' => ['ddl-risk_program_head'], 'placeholder' => 'เลือกอำเภอ...', 'url' => Url::to(['/riskhead/get-risk_program_detail'])]]); ?> </div> <?php echo $form->field($model, 'risk_program_text')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'login_name')->textInput(['maxlength' => true]);
/** * Finds the ProgramHead model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return ProgramHead the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = ProgramHead::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }