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/base/Field.php
#	src/base/Integration.php
#	src/elements/Form.php
#	src/elements/db/SentNotificationQuery.php
#	src/events/ModifyFieldIntegrationValueEvent.php
#	src/fields/Section.php
#	src/fields/Summary.php
#	src/helpers/ArrayHelper.php
#	src/helpers/Html.php
#	src/integrations/crm/ActiveCampaign.php
#	src/integrations/crm/MicrosoftDynamics365.php
#	src/integrations/crm/Salesforce.php
#	src/web/assets/forms/dist/assets/config.a46cce9c.js
#	src/web/assets/forms/dist/assets/config.a46cce9c.js.map
#	src/web/assets/forms/dist/assets/config.f615c9db.css
#	src/web/assets/forms/dist/assets/formie-form-new-EnYPERQ2.js.map
#	src/web/assets/forms/dist/assets/formie-form-new.095ea59c.js
#	src/web/assets/forms/dist/assets/formie-form-new.095ea59c.js.map
#	src/web/assets/forms/dist/assets/formie-form-new.b5f7c27a.js.map
#	src/web/assets/forms/dist/assets/formie-integration-settings.bcd5955d.js
#	src/web/assets/forms/dist/assets/formie-integration-settings.bcd5955d.js.map
#	src/web/assets/forms/dist/manifest.json
#	src/web/assets/forms/src/js/components/NotificationEditModal.vue
#	src/web/assets/forms/src/js/formkit/inputs/RichTextInput.vue
#	src/web/assets/forms/src/js/store/modules/form.js
#	src/web/assets/frontend/dist/css/formie-base.css
#	src/web/assets/frontend/dist/css/formie-theme.css
#	src/web/assets/frontend/dist/js/formie.js
  • Loading branch information
engram-design committed Mar 29, 2024
2 parents ec9b53b + a9112ea commit 8a28e88
Show file tree
Hide file tree
Showing 59 changed files with 3,568 additions and 103 deletions.
90 changes: 90 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,60 @@
- `Field::name` attribute has been deprecated. Use `Field::label` instead.
- `Field::inputHtml()` method has been deprecated. Use `Field::cpInputHtml()` instead.

## 2.1.8 - 2024-03-29

### Added
- Added “Source” to Klaviyo Email Marketing integration.
- Added support for additional SugarCRM fields.
- Added the ability for cosmetic fields (Heading, HTML, etc) to be included in email notifications.
- Added the ability to map to HubSpot Hidden fields.

### Changed
- Remove Section and Summary fields from rich text editor and variable picker options.

### Fixed
- Fixed Opayo and `1017` error responses.
- Fixed Algolia and Google address provider templates.
- Fixed Table fields not populating properly with `populateFormValues()` and allow usage of the column `handle`.
- Fixed Date/Time columns in Table field with timezone information when editing a submission in the control panel.
- Fixed Salesforce DateTime fields throwing an error.
- Fixed renamed theme config keys for some fields (wait until Formie 3).
- Fixed success/error messages containing paragraph tags not displaying correctly for Ajax-based forms.
- Fixed field and integration handles using the translated class name when they shouldn’t.
- Fixed cosmetic field handles not working correctly for non-English-default installs.
- Fixed a translation error in the control panel when the users language or site is set to German.
- Fixed some integrations throwing errors when the control panel language was set to non-English.

## 2.1.7 - 2024-03-18

### Added
- Added the ability to query `SentNotification` elements by `submissionId` and `notificationId`.
- Added “Subscribe Status” mapping option to ActiveCampaign integrations.
- Added `ModifyFieldIntegrationValueEvent::rawValue`.
- Added German Translations. (thanks @alexanderloewe).

### Changed
- Repeater/Group new-row templates now have spaceless HTML to take up less space in the page source.
- Update Monday integration mutation to latest API compatibility.
- Updated Form Template directories setting to auto-complete directories, not single templates.

### Fixed
- Fixed an error when viewing Stripe subscriptions in the control panel.
- Fixed failed Opayo 3DS payments creating a new payment model instead of updating the pending payment.
- Fixed Slack/Trello integration messages not including paragraph nodes.
- Fixed success/error/other form messages not including paragraph nodes.
- Fixed a reactivity issue when editing notifications, causing values to not always save.
- Fixed Slack webhooks not sending.
- Fixed Checkboxes/Radio field preview for horizontal layout and overflow.
- Fixed general errors, manually set to a submission’s `form` attribute not showing on the front-end.
- Fixed Theme Config not working correctly when supplying attributes with empty values (to output just the attribute like `readonly` or `disabled`) on elements.
- Customer information is now included for single Stripe payments.
- Fixed an error when rendering Payment fields with an invalid Payment integration.
- Fixed incorrect value when mapping to a Date field in HubSpot.
- Fixed `formie` translations not working correctly (defaulting to English) when there is a non-English primary site, and content has been written in non-English.
- Fixed scroll-offset calculation when scrolling to the top of a form.
- Fixed incorrect value when mapping to a Date field in HubSpot.

## 2.1.6 - 2024-03-03

### Added
Expand Down Expand Up @@ -1522,6 +1576,42 @@
- Fix lack of enter key accessibility for sent notification and submission modals in the control panel.
- Fix an issue using `populateFormValues` for Repeater fields.

## 1.6.40 - 2024-03-29

### Added
- Add support for additional SugarCRM fields.

## 1.6.39 - 2024-03-16

### Fixed
- Fixed Tiptap v1 and ProseMirror compatibility.

## 1.6.38 - 2024-03-13

### Fixed
- Fixed a Tiptap dependency causing the form builder to not load properly.

## 1.6.37 - 2024-03-08

### Fixed
- Fixed mutli-name fields that are conditionally hidden throwing an error in email notifications.
- Fixed a JS error when validating File Upload fields.

## 1.6.36.1 - 2023-12-12

### Changed
- Improve error message when failing to save a form.

### Fixed
- Fixed an error when creating new forms.

## 1.6.36 - 2023-12-12

### Fixed
- Fixed an error when form message settings contained emoji’s.
- Fixed lack of enter key accessibility for sent notification and submission modals in the control panel.
- Fixed an issue using `populateFormValues` for Repeater fields.

## 1.6.35 - 2023-10-25

### Added
Expand Down
20 changes: 20 additions & 0 deletions docs/template-guides/populating-forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ To populate a Repeater field, you'll also be creating the "blocks", as well as d

The above will create two "blocks" for the repeater field.

## Table
To populate a Table field, you'll also be creating the "rows", as well as defining the inner column values. The inner column values should be the `handle` for the column as defined in your field settings.

```twig
{% do craft.formie.populateFormValues(form, {
tableFieldHandle: [
{
textColumnHandle: 'Some Value',
dropdownColumnHandle: 'Option 1',
},
{
textColumnHandle: 'Another Value',
dropdownColumnHandle: 'Option 2',
},
],
}) %}
```

The above will create two "blocks" for the repeater field.

## Forcing Values
The method of populating field values in Formie is by setting the default value for a field. This means that when you start a new submission, the values you set in `populateFormValues()` will be applied to the field, the same way a default value would.

Expand Down
14 changes: 10 additions & 4 deletions docs/theming/template-overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ We recommend reading the [theming overview](docs:theming/overview) docs before g
The great thing about Formie's custom templates is that it doesn't have to be all-or-nothing. You can choose to override a single template, or all. For instance, you might have very specific markup needs to a Dropdown field. You can override just the template for the dropdown field, and nothing else.

## Form Templates
To get started, navigate to **Formie****Settings****Form Templates** and create a new template. If you're going to use **Use Custom Template**, we recommend you select **Copy Templates** when creating, so you can remove any HTML template you're not overriding, which will resolve back to Formie's defaults. That way, you're starting off with the templates Formie already uses as a basis for your custom templates.
To get started, navigate to **Formie****Settings****Form Templates** and create a new template. Enable the **Use Custom Template** setting to be able to define a template directory for your custom templates to sit. For example, if your templates exist in `templates/_forms`, you would enter `_forms`.

:::tip
Be sure to select a _directory_ when setting the template path, as there are multiple templates Formie can override. You can look at the [directory structure](https://github.com/verbb/formie/tree/craft-4/src/templates/_special/form-template) for more.
:::

You can also use the **Copy Templates** setting when creating, which will copy all of Formie's default templates into the directory you've specified. That way, you're starting off with the templates Formie already uses as a basis for your custom templates.

:::tip
You can't modify Formie's default Form Templates. Instead, you must create a new Form Template, and ensure your forms use that. This gives you the benefit of being able to easily manage _multiple_ custom templates across your forms.
Expand Down Expand Up @@ -44,7 +50,7 @@ Check out the raw templates on [Formie's GitHub](https://github.com/verbb/formie
:::

## Overriding Form Templates
To override the form template, provide a file named `form.html`.
To override the form template, provide a file named `form.html` in your template directory.

### Available Template Variables
Field templates have access to the following variables:
Expand All @@ -56,7 +62,7 @@ Variable | Description
`renderOptions` | A collection of [Render Options](docs:theming/render-options).

## Overriding Page Templates
To override the page template, provide a file named `page.html`.
To override the page template, provide a file named `page.html` in your template directory.

### Available Template Variables
Field templates have access to the following variables:
Expand All @@ -68,7 +74,7 @@ Variable | Description
`renderOptions` | A collection of [Render Options](docs:theming/render-options).

## Overriding Field Wrapper Templates
To override the field template, provide a file named `field.html`. This is the wrapper template around all fields. You can also override individual field types' templates, rather than changing the template for every field, regardless of type.
To override the field template, provide a file named `field.html` in your template directory. This is the wrapper template around all fields. You can also override individual field types' templates, rather than changing the template for every field, regardless of type.

### Available Template Variables
Field templates have access to the following variables:
Expand Down
9 changes: 9 additions & 0 deletions src/base/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ abstract class Field extends SavableComponent implements CraftFieldInterface, Fi
// Static Methods
// =========================================================================

public static function className(): string
{
$classNameParts = explode('\\', static::class);

return array_pop($classNameParts);
}

public static function phpType(): string
{
return 'mixed';
Expand Down Expand Up @@ -404,10 +411,12 @@ public function getValueForExport(mixed $value, ?ElementInterface $element = nul

public function getValueForIntegration(mixed $value, IntegrationField $integrationField, IntegrationInterface $integration, ?ElementInterface $element = null, string $fieldKey = ''): mixed
{
$rawValue = $value;
$value = $this->defineValueForIntegration($value, $integrationField, $integration, $element, $fieldKey);

$event = new ModifyFieldIntegrationValueEvent([
'value' => $value,
'rawValue' => $rawValue,
'field' => $this,
'submission' => $element,
'integrationField' => $integrationField,
Expand Down
12 changes: 11 additions & 1 deletion src/base/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ abstract class Integration extends SavableComponent implements IntegrationInterf
// Static Methods
// =========================================================================

public static function className(): string
{
$classNameParts = explode('\\', static::class);

return array_pop($classNameParts);
}

public static function isSelectable(): bool
{
return false;
Expand Down Expand Up @@ -261,7 +268,10 @@ public function getHandle(): string

public function getClassHandle(): string
{
return StringHelper::toKebabCase(static::displayName());
$classNameParts = explode('\\', static::class);
$end = array_pop($classNameParts);

return StringHelper::toKebabCase($end);
}

public function getEnabled(bool $parse = true): bool|string
Expand Down
2 changes: 1 addition & 1 deletion src/base/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public function defineHtmlTag(string $key, array $context = []): ?HtmlTag

protected function getIntegrationHandle(): string
{
return StringHelper::toKebabCase(static::displayName());
return StringHelper::toKebabCase(static::className());
}

/**
Expand Down
19 changes: 19 additions & 0 deletions src/base/PluginTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
use verbb\formie\services\Subscriptions;
use verbb\formie\web\assets\forms\FormsAsset;

use Craft;

use verbb\base\LogTrait;
use verbb\base\helpers\Plugin;
use verbb\base\services\Templates;
Expand Down Expand Up @@ -98,6 +100,23 @@ public static function config(): array
// Public Methods
// =========================================================================

public function __construct($id, $parent = null, array $config = [])
{
// Set the source language to be the current site, not `en-US`. We could have a German site (primary) where all field content
// is written in German. Then an English site we translate to. The German site will then show all texts in English as the source
// and destination message is the same, because it will translate to the `sourceLanguage` - `en-US`.
// This isn't an issue for other plugins, but we use the `formie` translation category to translate user-created content
// not just plugin-created content, which is always going to be written in English.
// Also, only do this for the front-end, so that the users' language preference is respected in the CP
if (Craft::$app->getRequest()->getIsSiteRequest()) {
if ($currentSite = Craft::$app->getSites()->getCurrentSite()) {
$config['sourceLanguage'] = $currentSite->language;
}
}

return parent::__construct($id, $parent , $config);
}

public function getEmails(): Emails
{
return $this->get('emails');
Expand Down
Loading

0 comments on commit 8a28e88

Please sign in to comment.