/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Instituicao::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(['idinstituicoes' => $this->idinstituicoes]); $query->andFilterWhere(['like', 'nomeinstituicao', $this->nomeinstituicao])->andFilterWhere(['like', 'enderecoinstituicao', $this->enderecoinstituicao])->andFilterWhere(['like', 'descricao', $this->descricao]); return $dataProvider; }
<div class="col-md-10"> <div class="col-md-5"> <?php echo $form->field($model, 'interessado')->widget(Select2::classname(), ['data' => ArrayHelper::map($interessados, 'id', 'cpf_nome'), 'options' => ['placeholder' => 'Selecione o Interessado ...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> </div> <hr> </div> <div class="row"> <div class="col-md-10"> <div class="col-md-5"> <?php echo $form->field($model, 'idinstituicoes')->dropDownList(ArrayHelper::map(\frontend\models\Instituicao::find()->all(), 'idinstituicoes', 'nomeinstituicao'), ['prompt' => 'Selecione']); ?> </div> </div> </div> <div class="row"> <div class="col-md-10"> <div class="col-md-5"> <?php echo $form->field($model, 'classe')->dropDownList(ArrayHelper::map(\frontend\models\Classes::find()->orderBy(['nome' => SORT_ASC])->all(), 'nome', 'nome'), ['prompt' => 'Selecione']); ?> </div> </div> </div>
/** * Finds the Instituicao model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Instituicao the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Instituicao::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getIdinstituicoes0() { return $this->hasOne(Instituicao::className(), ['idinstituicoes' => 'idinstituicoes']); }