/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = EquipmentStatus::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, 'active' => $this->active]); $query->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
/** * Finds the EquipmentStatus model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return EquipmentStatus the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = EquipmentStatus::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getEquipmentStatus() { return $this->hasOne(EquipmentStatus::className(), ['id' => 'equipment_status_id']); }
?> <?php echo $form->field($model, 'equipment_type_id')->dropDownList(ArrayHelper::map(EquipmentType::find()->orderBy('name ASC')->all(), 'id', 'name')); ?> <?php echo $form->field($model, 'description')->textArea(['maxlength' => true]); ?> <?php echo $form->field($model, 'serial_number')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'equipment_status_id')->dropDownList(ArrayHelper::map(EquipmentStatus::find()->orderBy('status ASC')->all(), 'id', 'status')); ?> <?php echo $form->field($model, 'room_id')->dropDownList(ArrayHelper::map(Room::find()->orderBy('name ASC')->all(), 'id', 'name'), ['prompt' => 'Selecciona un Salón...', 'onchange' => '$.post("' . Yii::$app->urlManager->createUrl('equipment/list-locations?id=') . '"+$(this).val(), function(data){ $("#equipment-location_id").html(data); })']); ?> <!--?= $form->field($model, 'location_id')->dropDownList( ArrayHelper::map( Location::find()->all(), 'id', 'location') )