|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
-
-
-
- namespace frontend\forms;
-
- use domain\User\User\UserModule;
- use yii\base\Model;
-
-
- class OpinionForm extends Model
- {
- public $name;
- public $email;
- public $message;
- public $verifyCode;
- public $isTest;
-
-
-
- public function rules()
- {
- $userModule = UserModule::getInstance();
- return [
- [['message'], 'required', 'message' => 'Champs obligatoire'],
- [['name', 'email'], 'required', 'message' => 'Champs obligatoire', 'when' => function($model) use($userModule) {
- return $userModule->isCurrentGuest();
- }],
- ['email', 'email', 'message' => 'Email incorrect'],
- ['isTest', 'string'],
- ['verifyCode', 'captcha', 'message' => 'Veuillez recopier le code de vérification', 'when' => function($model) use($userModule) {
- return $model->isTest != 'isTest' && $userModule->isCurrentGuest();
- }],
- ];
- }
-
-
-
- public function attributeLabels()
- {
- return [
- 'name' => 'Nom',
- 'email' => 'Email',
- 'message' => 'Message',
- 'verifyCode' => 'Code de vérification',
- ];
- }
- }
|