Answer the question
In order to leave comments, you need to log in
How to send name value from DropDownlist to model instead of ID?
In general, when processing an order, depending on the department, a certain list of doctors is available.
<?= $form2->field($modelC, 'doctor')->dropDownList(ArrayHelper::map(\app\modules\admin\models\Doctors::find()->where(['category_id' => $model->category_id])->all(), 'id','name'),['style'=>'font-family: \'Exo 2\', sans-serif; color: #0f0f0f; font-size:17px'])->label('Врач')?>
Answer the question
In order to leave comments, you need to log in
Good morning.
When generating a letter, get the doctor's full name by id and send it.
How do you send a letter, show.
How did you design the letter template?
ps
You get the doctor's id from the form. Using this id, you can get all the data about the doctor from the database, not only the name, but also some additional information. For example, the doctor's appointment hours are a month ahead.
public function getDoctor($id)
{
return Doctor::find()->where('id=:id', [':id' => $id])->one();
}
public function contact($email)
{
if ($this->validate()) {
Yii::$app->mailer->compose('order', [
'date' => $this->date,
'time' => $this->time,
'doctor' => $this->getDoctor($this->doctor),
'name' => $this->name
])
->setTo([$this->email])
->setFrom([$email =>$this->subject])
->setSubject('Подтвержение заказа')
->send();
return true;
}
return false;
}
// подставьте свои значения вместо name, patronymic, surname
echo "Врач: " . $doctor->name . ' ' . $doctor->patronymic . ' ' . $doctor->surname
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question