/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Especialidad::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(['idEspecialidad' => $this->idEspecialidad]); $query->andFilterWhere(['like', 'nombree', $this->nombree]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getIdEspecialidad0() { return $this->hasOne(Especialidad::className(), ['idEspecialidad' => 'idEspecialidad']); }
/** * Finds the Especialidad model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Especialidad the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Especialidad::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php echo $form->field($model, 'telefono')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'celular')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'correo')->textInput(['maxlength' => 50, 'placeholder' => '*****@*****.**']); ?> <?php echo $form->field($model, 'idEspecialidad')->widget(Select2::classname(), ['data' => ArrayHelper::map(Especialidad::find()->all(), 'idEspecialidad', 'nombree'), 'language' => 'en', 'options' => ['placeholder' => ''], 'pluginOptions' => ['allowClear' => true]]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Guardar' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>