/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Raca::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['idRaca' => $this->idRaca]); $query->andFilterWhere(['like', 'designacao', $this->designacao]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getIdRaca0() { return $this->hasOne(Raca::className(), ['idRaca' => 'idRaca']); }
/** * Finds the Raca model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Raca the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Raca::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
?> <?php echo $form->field($model, 'nrPai')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'nrMae')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'idEspecie')->dropDownList(ArrayHelper::map(Especie::find()->all(), 'idEspecie', 'designacao'), ['prompt' => 'Escolher Espécie']); ?> <?php echo $form->field($model, 'idRaca')->dropDownList(ArrayHelper::map(Raca::find()->all(), 'idRaca', 'designacao'), ['prompt' => 'Escolher Raça']); ?> <?php echo $form->field($model, 'idRebanho')->dropDownList(ArrayHelper::map(Rebanho::find()->all(), 'idRebanho', 'designacao'), ['prompt' => 'Escolher Rebanho']); ?> <?php echo $form->field($model, 'idNucleo')->dropDownList(ArrayHelper::map(Nucleo::find()->all(), 'idNucleo', 'nome'), ['prompt' => 'Escolher Núcleo']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Inserir' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>