Skip to content

Commit

Permalink
Merge branch 'craft-4' of https://github.com/verbb/formie into craft-5
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	composer.json
#	src/controllers/FormsController.php
#	src/models/Phone.php
  • Loading branch information
engram-design committed May 29, 2024
2 parents 6c355ac + 105237c commit 9647d79
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,17 @@
- `Field::name` attribute has been deprecated. Use `Field::label` instead.
- `Field::inputHtml()` method has been deprecated. Use `Field::cpInputHtml()` instead.

## 2.1.17 - 2024-05-29

### Changed
- Ensure that sessions exists when calling `formie/forms/refresh-tokens`.

### Fixed
- Fixed element integrations update matching logic where matched data is empty.
- Fixed `populateFormValues` values and dynamic Twig.
- Fixed an error with Phone number fields and `countryCode`.
- Fixed an error with Phone number fields and `countryName`.

## 2.1.16 - 2024-05-27

### Added
Expand Down
7 changes: 6 additions & 1 deletion src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,12 @@ protected function getElementForPayload(string $elementType, string $identifier,
$updateElementValues = $this->getFieldMappingValues($submission, $this->updateElementMapping, $updateAttributes);
$updateElementValues = array_filter($updateElementValues);

// Merge in any extra criteria
// Something must be mapped in order to find an element, otherwise it'll just find any element for the criteria
if (!$updateElementValues) {
return $element;
}

// Merge in any extra criteria supplied by the element integration class
$updateElementValues = array_merge($updateElementValues, $criteria);

if ($updateElementValues) {
Expand Down
4 changes: 4 additions & 0 deletions src/controllers/FormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use craft\db\Query;
use craft\helpers\DateTimeHelper;
use craft\helpers\Json;
use craft\helpers\Session;
use craft\helpers\UrlHelper;
use craft\models\Site;
use craft\web\Controller;
Expand Down Expand Up @@ -309,6 +310,9 @@ public function actionDeleteForm(): ?Response

public function actionRefreshTokens(): Response
{
// Ensure that the session has started, just in case
Session::exists();

$params = [
'csrf' => [
'param' => $this->request->csrfParam,
Expand Down
6 changes: 5 additions & 1 deletion src/models/Phone.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ public static function toPhoneString(mixed $value): string

public function __construct($config = [])
{
// Normalize the options
// Normalize the settings. Included in `toArray` for integrations, but not actively in use. Potentially refactor.
if (array_key_exists('countryCode', $config)) {
unset($config['countryCode']);
}

if (array_key_exists('countryName', $config)) {
unset($config['countryName']);
}

parent::__construct($config);
}

Expand Down
4 changes: 2 additions & 2 deletions src/services/Rendering.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ public function populateFormValues($element, $values = [], $force = false): void
try {
$field = $form->getFieldByHandle($key);

// Ensure that we protect against developers using Twig to populate values from query strings
// Prevent users using long-hand Twig `{{` to prevent injection execution. Only an issue for some fields like Hidden fields.
if (is_string($value)) {
$value = Formie::$plugin->getTemplates()->renderString($value);
$value = str_replace(['{{', '}}', '{%', '%}'], ['{', '}', '', ''], $value);
}

if ($field) {
Expand Down
13 changes: 10 additions & 3 deletions src/translations/en/formie.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<?php

return [
//
// Email Messages
//
'formie_failed_notification_heading' => 'When an email notification fails to send:',
'formie_failed_notification_subject' => 'Email notification failed to send for form "{{ form.title }}" on {{ siteName }}.',
'formie_failed_notification_body' => "An email notification for the form “{{ form.title }}” has failed to send.\n\n" .
"The error response was recorded: {{ emailResponse | json_encode }}.\n\n" .
"To review it please log into your control panel.\n\n" .
"{{ submission.cpEditUrl }}",

'"{label}" should contain at most {max, number} {max, plural, one{character} other{characters}}.' => '"{label}" should contain at most {max, number} {max, plural, one{character} other{characters}}.',
'(GDPR) {text}' => '(GDPR) {text}',
'(optional)' => '(optional)',
Expand Down Expand Up @@ -1027,9 +1037,6 @@
'Form Field Mapping' => 'Form Field Mapping',
'Form Fields' => 'Form Fields',
'Formie' => 'Formie',
'formie_failed_notification_body' => 'formie_failed_notification_body',
'formie_failed_notification_heading' => 'formie_failed_notification_heading',
'formie_failed_notification_subject' => 'formie_failed_notification_subject',
'Form imported.' => 'Form imported.',
'Form Name' => 'Form Name',
'Forms' => 'Forms',
Expand Down

0 comments on commit 9647d79

Please sign in to comment.