/** * Finds the Specialty model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Specialty the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Specialty::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/* @var $model app\modules\appointment\models\Physician */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="physician-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'not_accept')->checkbox(); ?> <?php echo $form->field($model, 'specialty_id')->dropDownList(Specialty::getList()); ?> <?php echo $form->field($model, 'snils')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'last_name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'first_name')->textInput(['maxlength' => true]); ?> <?php
<?php $form = ActiveForm::begin(); ?> <div class="row"> <div class="col-sm-6 specialty"> <div class="well"> <h4><?php echo $model->getAttributeLabel('specialty_id'); ?> </h4> <?php echo $form->field($model, 'specialty_id')->dropDownList(Specialty::getList($patient->physicianSpecialty), ['prompt' => '-'])->label(false); ?> </div> </div> <div class="col-sm-6 physician" style="display: none;"> <div class="well"> <h4><?php echo $model->getAttributeLabel('physician_id'); ?> </h4> <?php echo $form->field($model, 'physician_id')->dropDownList(Physician::getList(null, $patient->physician_id), ['prompt' => '-'])->label(false); ?> </div>
public static function getList($specialty_id = null, $physician_id = null) { if ($specialty_id !== null) { $specialty = Specialty::findOne($specialty_id); if ($specialty !== null && $physician_id !== null) { $model = static::findOne($physician_id); if ($model !== null && $specialty->is_therapist) { return [$model->physician_id => $model->fullName]; } } } $models = $specialty_id === null ? static::find()->all() : static::find()->where(['specialty_id' => $specialty_id])->all(); return ArrayHelper::map($models, 'physician_id', 'fullName'); }