[ 'name', 'email', 'message', 'returnUrl', 'subject' ], self::SCENARIO_CALLBACK => [ 'name', 'phone', 'message', 'returnUrl', 'subject' ], ] ); return $scenarios; } public function rules() { return [ [ [ 'name', 'email', 'phone', ], 'required', 'on' => self::SCENARIO_DEFAULT, ], [ [ 'name', 'email', ], 'required', 'on' => self::SCENARIO_FEEDBACK, ], [ [ 'phone', 'name', ], 'required', 'on' => self::SCENARIO_CALLBACK, ], [ [ 'email' ], 'email', ], // [ // [ 'phone' ], // 'match', // 'pattern' => '/^\+38\(\d{3}\)\d{3}-\d{2}-\d{2}$/', // ], [ [ 'name', 'phone', 'email', 'subject', ], 'string', 'max' => 255, ], [ [ 'message', ], 'string', ], [ [ 'status', ], 'boolean', ], [ 'returnUrl', 'safe', ], ]; } public function attributeLabels() { return array_merge( parent::attributeLabels(), [ 'subject' => \Yii::t('app', 'subject'), ] ); } }