Skip to content

Commit

Permalink
Merge branch 'v2' of https://github.com/craftcms/contact-form into main
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	README.md
  • Loading branch information
brandonkelly committed Mar 11, 2024
2 parents 0a42daa + c5baf99 commit 1b76c22
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Added Craft 5 compatibility.
- Added a missing Dutch translation. ([#257](https://github.com/craftcms/contact-form/issues/257))
- Fixed a bug where it wasn’t possible to upload a single file with the `attachment` param. ([#254](https://github.com/craftcms/contact-form/issues/254))

## 3.0.1 - 2023-03-16

Expand All @@ -22,7 +23,7 @@

## 2.5.2 - 2023-03-16

- Added translations for for `Email` and `Name`. ([#235](https://github.com/craftcms/contact-form/issues/235))
- Added translations for `Email` and `Name`. ([#235](https://github.com/craftcms/contact-form/issues/235))

## 2.5.1 - 2022-05-02

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ return [

### Overriding plugin settings

If you create a [config file](https://craftcms.com/docs/4.x/config/general.html) in your `config/` folder called `contact-form.php`, you can override
If you create a [config file](https://craftcms.com/docs/4.x/config/) in your `config/` folder called `contact-form.php`, you can override
the plugin’s settings in the Control Panel. Since that config file is fully [multi-environment](https://craftcms.com/docs/4.x/config/#multi-environment-configs) aware, this is
a handy way to have different settings across multiple environments.

Expand Down
4 changes: 4 additions & 0 deletions src/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public function send(Submission $submission, bool $runValidation = true): bool
if ($submission->attachment !== null) {
$allowedFileTypes = Craft::$app->getConfig()->getGeneral()->allowedFileExtensions;

if (!is_array($submission->attachment)) {
$submission->attachment = [$submission->attachment];
}

foreach ($submission->attachment as $attachment) {
if (!$attachment) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/SendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function actionIndex()
if (is_array($_FILES['attachment']['name'])) {
$submission->attachment = UploadedFile::getInstancesByName('attachment');
} else {
$submission->attachment = [UploadedFile::getInstanceByName('attachment')];
$submission->attachment = UploadedFile::getInstanceByName('attachment');
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/models/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class Submission extends Model
public $message;

/**
* @var UploadedFile[]|null[]|null
* @phpstan-var array<UploadedFile|null>|null
* @var UploadedFile|UploadedFile[]|null[]|null
* @phpstan-var UploadedFile|array<UploadedFile|null>|null
*/
public $attachment;

Expand Down

0 comments on commit 1b76c22

Please sign in to comment.