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