/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Yemekler::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(['id' => $this->id, 'kalori' => $this->kalori]);
     $query->andFilterWhere(['like', 'yemekName', $this->yemekName])->andFilterWhere(['like', 'ogunid', $this->ogunid]);
     return $dataProvider;
 }
Exemplo n.º 2
0
<div class="kalori-table-form">

    <?php 
$form = ActiveForm::begin();
?>
    
        <?php 
echo $form->field($model, 'userid')->textInput(['readonly' => true, 'value' => Yii::$app->user->identity->username])->label("Kullanıcı Adı");
$model->userid = Yii::$app->user->identity->id;
echo $form->field($model, 'meal')->dropDownList(ArrayHelper::map(Ogun::find()->all(), 'Name', 'Name'), ['prompt' => 'Öğün Seçiniz', 'onchange' => '$.post("index.php?r=admin/yemekler-kalori/lists&ogun=' . '"+$(this).val(), function(data){
                    $("select#kaloritable-yemekname").html(data);});'])->label("Öğün Seçiniz");
?>
    
    <?php 
echo $form->field($model, 'YemekName')->dropDownList(ArrayHelper::map(Yemekler::find()->all(), 'yemekName', 'yemekName'), ['prompt' => 'Yemek Seçiniz', 'onchange' => '$.post("index.php?r=admin/yemekler-kalori/kalori&yemekName=' . '"+$(this).val(), function(data){
                    $("#kaloritable-kalori").html(data);});'])->label("Yemek Seçiniz");
?>

    
    <?php 
echo $form->field($model, 'Tarih')->widget(DatePicker::className(), ['inline' => false, 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-m-dd', 'startDate' => date('1960-01-01'), 'endDate' => date('')]]);
?>
    <?php 
echo $form->field($model, 'kalori')->dropDownList(['prompt' => 'kalori değeri'])->label("kalori");
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
 /**
  * Finds the Yemekler model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Yemekler the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Yemekler::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }