diff --git a/models/ContactForm.php b/models/ContactForm.php index c8c8e05..c2ed625 100755 --- a/models/ContactForm.php +++ b/models/ContactForm.php @@ -38,26 +38,30 @@ public function rules() public function attributeLabels() { return [ - 'name' => Yii::t('app', 'Name'), - 'email' => Yii::t('app', 'Email'), - 'subject' => Yii::t('app', 'Subject'), - 'body' => Yii::t('app', 'Body'), - 'lastname' => Yii::t('app', 'Lastname'), + 'name' => Yii::t('contact', 'Name'), + 'email' => Yii::t('contact', 'Email'), + 'subject' => Yii::t('contact', 'Subject'), + 'body' => Yii::t('contact', 'Body'), + 'lastname' => Yii::t('contact', 'Lastname'), ]; } /** * Sends an email to the specified email address using the information collected by this model. * - * @param string $email the target email address + * @param string $email the target and source email address * @return bool whether the email was sent */ public function sendEmail($email) { return Yii::$app->mailer->compose() ->setTo($email) - ->setFrom([$this->email => $this->name]) - ->setSubject($this->subject) + ->setFrom([$email => Yii::$app->name]) + ->setReplyTo([$this->email => $this->name]) + ->setSubject($this->subject ?: Yii::t('contact', '{name} in {website}', [ + 'name' => $this->name, + 'website' => Yii::$app->name + ])) ->setTextBody($this->body) ->send(); } diff --git a/views/default/contact.php b/views/default/contact.php index 516d95a..3f32cc0 100755 --- a/views/default/contact.php +++ b/views/default/contact.php @@ -8,8 +8,11 @@ use yii\helpers\Html; use yii\bootstrap\ActiveForm; -$this->title = 'Contact'; -$this->params['breadcrumbs'][] = $this->title; +if (!$renderPartial) { + $this->title = 'Contact'; + $this->params['breadcrumbs'][] = $this->title; +} + ?>