|
|
@@ -44,7 +44,8 @@ use yii\base\Model; |
|
|
|
/** |
|
|
|
* ContactForm is the model behind the contact form. |
|
|
|
*/ |
|
|
|
class ContactForm extends Model { |
|
|
|
class ContactForm extends Model |
|
|
|
{ |
|
|
|
|
|
|
|
public $name; |
|
|
|
public $email; |
|
|
@@ -55,7 +56,8 @@ class ContactForm extends Model { |
|
|
|
/** |
|
|
|
* @inheritdoc |
|
|
|
*/ |
|
|
|
public function rules() { |
|
|
|
public function rules() |
|
|
|
{ |
|
|
|
return [ |
|
|
|
// name, email, subject and body are required |
|
|
|
[['name', 'email', 'subject', 'body'], 'required', 'message' => 'Champs obligatoire'], |
|
|
@@ -69,7 +71,8 @@ class ContactForm extends Model { |
|
|
|
/** |
|
|
|
* @inheritdoc |
|
|
|
*/ |
|
|
|
public function attributeLabels() { |
|
|
|
public function attributeLabels() |
|
|
|
{ |
|
|
|
return [ |
|
|
|
'name' => 'Nom', |
|
|
|
'email' => 'Email', |
|
|
@@ -85,7 +88,8 @@ class ContactForm extends Model { |
|
|
|
* @param string $email the target email address |
|
|
|
* @return boolean whether the email was sent |
|
|
|
*/ |
|
|
|
public function sendEmail($email) { |
|
|
|
public function sendEmail($email) |
|
|
|
{ |
|
|
|
|
|
|
|
return Yii::$app->mailer->compose([ |
|
|
|
'html' => 'contact-html', |