Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Rebanho::find();
     $query->joinWith('relIdNucleo');
     // 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(['idRebanho' => $this->idRebanho]);
     $query->andFilterWhere(['like', 'designacao', $this->designacao])->andFilterWhere(['like', 'Nucleo.nome', $this->idNucleo]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRelIdRebanho()
 {
     return $this->hasOne(Rebanho::className(), ['idRebanho' => 'idRebanho']);
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRebanhos()
 {
     return $this->hasMany(Rebanho::className(), ['idNucleo' => 'idNucleo']);
 }
Пример #4
0
 /**
  * Finds the Rebanho model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Rebanho the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Rebanho::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #5
0
?>

    <?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>

    <?php 
ActiveForm::end();
?>